Changeset 77c1abe
- Timestamp:
- 2007-08-20T04:05:51Z (17 years ago)
- Branches:
- master
- Children:
- 8dd21bb
- Parents:
- 0bb1b7f
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
skype/skype.c
r0bb1b7f r77c1abe 18 18 int tx_len; 19 19 int r_inpa, w_inpa; 20 // when we receive a new message id, we query the handle, then the body 21 // store the handle here 22 // TODO: it would be nicer to use a hashmap for this or something 23 char *handle; 20 24 }; 21 25 … … 107 111 ptr = g_strdup_printf("%s@skype.com", user); 108 112 imcb_add_buddy(ic, ptr, NULL); 109 // TODO online can be away110 113 if(strcmp(status, "OFFLINE") != 0) 111 114 flags |= OPT_LOGGED_IN; … … 114 117 imcb_buddy_status(ic, ptr, flags, NULL, NULL); 115 118 g_free(ptr); 119 } 120 else if(!strncmp(line, "CHATMESSAGE ", 12)) 121 { 122 char *id = strchr(line, ' '); 123 if(++id) 124 { 125 char *info = strchr(id, ' '); 126 *info = '\0'; 127 info++; 128 if(!strcmp(info, "STATUS RECEIVED")) 129 { 130 // new message, request its body 131 printf("new received message #%s\n", id); 132 g_snprintf(buf, 1024, "GET CHATMESSAGE %s FROM_HANDLE\n", id); 133 skype_write( ic, buf, strlen( buf ) ); 134 g_snprintf(buf, 1024, "GET CHATMESSAGE %s BODY\n", id); 135 skype_write( ic, buf, strlen( buf ) ); 136 } 137 else if(!strncmp(info, "FROM_HANDLE ", 12)) 138 { 139 info += 12; 140 // new handle 141 sd->handle = g_strdup_printf("%s@skype.com", info); 142 printf("new handle: '%s'\n", info); 143 } 144 else if(!strncmp(info, "BODY ", 5)) 145 { 146 info += 5; 147 // new body 148 printf("<%s> %s\n", sd->handle, info); 149 imcb_buddy_msg(ic, sd->handle, info, 0, 0); 150 g_free(sd->handle); 151 sd->handle = NULL; 152 } 153 } 116 154 } 117 155 lineptr++; … … 175 213 sd->fd = proxy_connect(acc->server, set_getint( &acc->set, "port" ), skype_connected, ic ); 176 214 printf("sd->fd: %d\n", sd->fd); 215 /*imcb_add_buddy(ic, "test@skype.com", NULL); 216 imcb_buddy_status(ic, "test@skype.com", OPT_LOGGED_IN, NULL, NULL); 217 imcb_buddy_msg(ic, "test@skype.com", "test from skype plugin", 0, 0);*/ 177 218 178 219 sd->ic = ic; … … 187 228 static int skype_buddy_msg( struct im_connection *ic, char *who, char *message, int flags ) 188 229 { 189 char *buf, *ptr ;230 char *buf, *ptr, *nick; 190 231 int st; 191 232 192 ptr = strchr(who, '@'); 233 nick = g_strdup_printf("%s", who); 234 ptr = strchr(nick, '@'); 193 235 if(ptr) 194 236 *ptr = '\0'; 195 237 196 buf = g_strdup_printf("MESSAGE %s %s\n", who, message); 238 buf = g_strdup_printf("MESSAGE %s %s\n", nick, message); 239 g_free(nick); 197 240 st = skype_write( ic, buf, strlen( buf ) ); 198 241 g_free(buf);
Note: See TracChangeset
for help on using the changeset viewer.