diff src/protocols/sametime/sametime.c @ 12311:a2ebf585d8c6

[gaim-migrate @ 14615] should work fine, but I have to go home now. This ought to clean up all the signedness warnings, start to remove some unnecessary features (server-stored status messages), and add a useful feature (pretending to be an official client when the server is blocking unofficial clients) committer: Tailor Script <tailor@pidgin.im>
author Christopher O'Brien <siege@pidgin.im>
date Sun, 04 Dec 2005 04:09:30 +0000
parents 0e467757b57a
children 1c8ea8f3b84e
line wrap: on
line diff
--- a/src/protocols/sametime/sametime.c	Sun Dec 04 02:53:47 2005 +0000
+++ b/src/protocols/sametime/sametime.c	Sun Dec 04 04:09:30 2005 +0000
@@ -148,6 +148,7 @@
 #define MW_KEY_INVITE      "conf_invite"
 #define MW_KEY_ENCODING    "encoding"
 #define MW_KEY_FORCE       "force_login"
+#define MW_KEY_FAKE_IT     "fake_client_id"
 
 
 /** number of seconds from the first blist change before a save to the
@@ -341,7 +342,7 @@
 
 
 static int mw_session_io_write(struct mwSession *session,
-			       const char *buf, gsize len) {
+			       const guchar *buf, gsize len) {
   struct mwGaimPluginData *pd;
   int ret = 0;
 
@@ -1618,7 +1619,7 @@
     pass it to the session, passing back the return code from the read
     call for handling in read_cb */
 static int read_recv(struct mwSession *session, int sock) {
-  char buf[BUF_LEN];
+  guchar buf[BUF_LEN];
   int len;
 
   len = read(sock, buf, BUF_LEN);
@@ -2106,7 +2107,7 @@
 
 
 static void ft_send(struct mwFileTransfer *ft, FILE *fp) {
-  char buf[BUF_LONG];
+  guchar buf[BUF_LONG];
   struct mwOpaque o = { .data = buf, .len = BUF_LONG };
   guint32 rem;
   GaimXfer *xfer;
@@ -3645,7 +3646,7 @@
   struct mwGaimPluginData *pd;
 
   char *user, *pass, *host;
-  guint port;
+  guint port, client;
 
   gc = gaim_account_get_connection(account);
   pd = mwGaimPluginData_new(gc);
@@ -3685,8 +3686,15 @@
 			(char *) no_secret, NULL);
   mwSession_setProperty(pd->session, mwSession_AUTH_USER_ID, user, g_free);
   mwSession_setProperty(pd->session, mwSession_AUTH_PASSWORD, pass, NULL);
+
+  client = MW_CLIENT_TYPE_ID;
+  if(gaim_account_get_bool(account, MW_KEY_FAKE_IT, FALSE))
+    client = mwLogin_BINARY;
+
+  DEBUG_INFO("client id: 0x%04x\n", client);
+
   mwSession_setProperty(pd->session, mwSession_CLIENT_TYPE_ID,
-			GUINT_TO_POINTER(MW_CLIENT_TYPE_ID), NULL);
+			GUINT_TO_POINTER(client), NULL);
 
   gaim_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS);
 
@@ -4065,6 +4073,58 @@
 }
 
 
+static const char *mw_client_name(guint16 type) {
+  switch(type) {
+  case mwLogin_LIB:
+    return "Lotus Binary Library";
+    
+  case mwLogin_JAVA_WEB:
+    return "Lotus Java Client Applet";
+
+  case mwLogin_BINARY:
+    return "Lotus Sametime Connect";
+
+  case mwLogin_JAVA_APP:
+    return "Lotus Java Client Application";
+
+  case mwLogin_LINKS:
+    return "Lotus Sametime Links";
+
+  case mwLogin_NOTES_6_5:
+  case mwLogin_NOTES_6_5_3:
+  case mwLogin_NOTES_7_0_beta:
+  case mwLogin_NOTES_7_0:
+    return "Lotus Notes Client";
+
+  case mwLogin_ICT:
+  case mwLogin_ICT_1_7_8_2:
+  case mwLogin_ICT_SIP:
+    return "IBM Community Tools";
+
+  case mwLogin_NOTESBUDDY_4_14:
+  case mwLogin_NOTESBUDDY_4_15:
+  case mwLogin_NOTESBUDDY_4_16:
+    return "Alphaworks NotesBuddy";
+
+  case mwLogin_SANITY:
+    return "Sanity";
+
+  case mwLogin_ST_PERL:
+    return "ST-Send-Message";
+
+  case mwLogin_TRILLIAN:
+  case mwLogin_TRILLIAN_IBM:
+    return "Trillian";
+
+  case mwLogin_MEANWHILE:
+    return "Meanwhile";
+
+  default:
+    return NULL;
+  }
+}
+
+
 static void mw_prpl_get_info(GaimConnection *gc, const char *who) {
 
   struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL };
@@ -4104,7 +4164,7 @@
     if(type) {
       g_string_append(str, _("<b>Last Known Client:</b> "));
 
-      tmp = mwLoginType_getName(type);
+      tmp = mw_client_name(type);
       if(tmp) {
 	g_string_append(str, tmp);
 	g_string_append(str, "<br>");
@@ -5201,6 +5261,7 @@
 };
 
 
+#if 0
 static void status_msg_action_cb(GaimConnection *gc,
 				 GaimRequestFields *fields) {
   GaimAccount *acct;
@@ -5234,7 +5295,6 @@
   unit = mwStorageUnit_newString(mwStore_BUSY_MESSAGES, msg);
   mwServiceStorage_save(srvc, unit, NULL, NULL, NULL);
 
-#if 0
   /* XXX */
   /* need to propagate the message change if we're in any of those
      default states */
@@ -5248,7 +5308,6 @@
   }
   if(msg)
     serv_set_away(gc, msg, NULL);
-#endif
 }
 
 
@@ -5300,6 +5359,7 @@
 		      _("Cancel"), NULL,
 		      gc);
 }
+#endif
 
 
 static void st_import_action_cb(GaimConnection *gc, char *filename) {
@@ -5608,9 +5668,11 @@
   GaimPluginAction *act;
   GList *l = NULL;
 
+#if 0
   act = gaim_plugin_action_new(_("Set Status Messages..."),
 			       status_msg_action);
   l = g_list_append(l, act);
+#endif
 
   act = gaim_plugin_action_new(_("Import Sametime List..."),
 			       st_import_action);
@@ -5732,6 +5794,10 @@
     l = g_list_append(l, opt);
   }
 
+  /* pretend to be Sametime Connect */
+  opt = gaim_account_option_bool_new(_("Hide Client Identity"),
+				     MW_KEY_FAKE_IT, FALSE);
+
   mw_prpl_info.protocol_options = l;
   l = NULL;