Mercurial > pidgin.yaz
comparison plugins/gaim-remote/remote.c @ 10395:b4b9dabdd7c7
[gaim-migrate @ 11624]
Some whitespace fixes, a compile warning fix, and add a "logout" option
to gaim-remote
committer: Tailor Script <tailor@pidgin.im>
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Fri, 17 Dec 2004 23:30:38 +0000 |
parents | 5976491e07a7 |
children | 3e4ecbdf8d0a |
comparison
equal
deleted
inserted
replaced
10394:45a0a07e8b25 | 10395:b4b9dabdd7c7 |
---|---|
93 /* aim:goim?screenname=screenname&message=message */ | 93 /* aim:goim?screenname=screenname&message=message */ |
94 if (!g_ascii_strncasecmp(uri, "aim:goim?", strlen("aim:goim?"))) { | 94 if (!g_ascii_strncasecmp(uri, "aim:goim?", strlen("aim:goim?"))) { |
95 char *who, *what; | 95 char *who, *what; |
96 GaimConversation *c; | 96 GaimConversation *c; |
97 uri = uri + strlen("aim:goim?"); | 97 uri = uri + strlen("aim:goim?"); |
98 | 98 |
99 if (!(who = strstr(uri, "screenname="))) { | 99 if (!(who = strstr(uri, "screenname="))) { |
100 return _("No screenname given."); | 100 return _("No screenname given."); |
101 } | 101 } |
102 /* spaces are encoded as +'s */ | 102 /* spaces are encoded as +'s */ |
103 who = who + strlen("screenname="); | 103 who = who + strlen("screenname="); |
106 g_string_append_c(str, *who == '+' ? ' ' : *who); | 106 g_string_append_c(str, *who == '+' ? ' ' : *who); |
107 who++; | 107 who++; |
108 } | 108 } |
109 who = g_strdup(str->str); | 109 who = g_strdup(str->str); |
110 g_string_free(str, TRUE); | 110 g_string_free(str, TRUE); |
111 | 111 |
112 what = strstr(uri, "message="); | 112 what = strstr(uri, "message="); |
113 if (what) { | 113 if (what) { |
114 what = what + strlen("message="); | 114 what = what + strlen("message="); |
115 str = g_string_new(NULL); | 115 str = g_string_new(NULL); |
116 while (*what && (*what != '&' || !g_ascii_strncasecmp(what, "&", 5))) { | 116 while (*what && (*what != '&' || !g_ascii_strncasecmp(what, "&", 5))) { |
166 g_free(group); | 166 g_free(group); |
167 } else if (!g_ascii_strncasecmp(uri, "aim:gochat?", strlen("aim:gochat?"))) { | 167 } else if (!g_ascii_strncasecmp(uri, "aim:gochat?", strlen("aim:gochat?"))) { |
168 char *room; | 168 char *room; |
169 GHashTable *components; | 169 GHashTable *components; |
170 int exch = 5; | 170 int exch = 5; |
171 | 171 |
172 uri = uri + strlen("aim:gochat?"); | 172 uri = uri + strlen("aim:gochat?"); |
173 /* spaces are encoded as +'s */ | 173 /* spaces are encoded as +'s */ |
174 | 174 |
175 if (!(room = strstr(uri, "roomname="))) { | 175 if (!(room = strstr(uri, "roomname="))) { |
176 return _("No roomname given."); | 176 return _("No roomname given."); |
177 } | 177 } |
178 room = room + strlen("roomname="); | 178 room = room + strlen("roomname="); |
179 str = g_string_new(NULL); | 179 str = g_string_new(NULL); |
192 serv_join_chat(gc, components); | 192 serv_join_chat(gc, components); |
193 g_hash_table_destroy(components); | 193 g_hash_table_destroy(components); |
194 } else { | 194 } else { |
195 return _("Invalid AIM URI"); | 195 return _("Invalid AIM URI"); |
196 } | 196 } |
197 | 197 |
198 | |
199 return NULL; | 198 return NULL; |
200 } | 199 } |
201 | 200 |
202 | 201 |
203 | 202 |
303 static void | 302 static void |
304 meta_handler(struct UI *ui, guchar subtype, gchar *data) | 303 meta_handler(struct UI *ui, guchar subtype, gchar *data) |
305 { | 304 { |
306 GaimRemotePacket *p; | 305 GaimRemotePacket *p; |
307 GError *error = NULL; | 306 GError *error = NULL; |
307 | |
308 switch (subtype) { | 308 switch (subtype) { |
309 case CUI_META_LIST: | 309 case CUI_META_LIST: |
310 break; | 310 break; |
311 case CUI_META_QUIT: | 311 case CUI_META_QUIT: |
312 while (uis) { | 312 while (uis) { |
414 case CUI_USER_BACK: | 414 case CUI_USER_BACK: |
415 do_im_back(NULL, NULL); | 415 do_im_back(NULL, NULL); |
416 break; | 416 break; |
417 | 417 |
418 #endif /* STATUS */ | 418 #endif /* STATUS */ |
419 | |
420 case CUI_USER_LOGOUT: | |
421 gaim_connections_disconnect_all(); | |
422 break; | |
423 | |
419 default: | 424 default: |
420 gaim_debug_warning("cui", "Unhandled user subtype %d\n", subtype); | 425 gaim_debug_warning("cui", "Unhandled user subtype %d\n", subtype); |
421 break; | 426 break; |
422 } | 427 } |
423 } | 428 } |
680 break; | 685 break; |
681 /* | 686 /* |
682 case CUI_TYPE_CHAT: | 687 case CUI_TYPE_CHAT: |
683 chat_handler(ui, subtype, in); | 688 chat_handler(ui, subtype, in); |
684 break; | 689 break; |
685 */ | 690 */ |
686 case CUI_TYPE_REMOTE: | 691 case CUI_TYPE_REMOTE: |
687 remote_handler(ui, subtype, in, len); | 692 remote_handler(ui, subtype, in, len); |
688 break; | 693 break; |
689 default: | 694 default: |
690 gaim_debug_warning("cui", "Unhandled type %d\n", type); | 695 gaim_debug_warning("cui", "Unhandled type %d\n", type); |
691 break; | 696 break; |
692 } | 697 } |
693 | 698 |
722 static gint | 727 static gint |
723 open_socket(char **error) | 728 open_socket(char **error) |
724 { | 729 { |
725 struct sockaddr_un saddr; | 730 struct sockaddr_un saddr; |
726 gint fd; | 731 gint fd; |
727 | 732 |
728 while (gaim_remote_session_exists(gaim_session)) | 733 while (gaim_remote_session_exists(gaim_session)) |
729 gaim_session++; | 734 gaim_session++; |
730 | 735 |
731 gaim_debug_misc("cui", "Session: %d\n", gaim_session); | 736 gaim_debug_misc("cui", "Session: %d\n", gaim_session); |
732 | 737 |
733 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { | 738 if ((fd = socket(AF_UNIX, SOCK_STREAM, 0)) != -1) { |
734 mode_t m = umask(0177); | 739 mode_t m = umask(0177); |
735 saddr.sun_family = AF_UNIX; | 740 saddr.sun_family = AF_UNIX; |
736 | 741 |
737 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", | 742 g_snprintf(saddr.sun_path, sizeof(saddr.sun_path), "%s" G_DIR_SEPARATOR_S "gaim_%s.%d", |
740 listen(fd, 100); | 745 listen(fd, 100); |
741 else { | 746 else { |
742 *error = g_strdup_printf(_("Failed to assign %s to a socket:\n%s"), | 747 *error = g_strdup_printf(_("Failed to assign %s to a socket:\n%s"), |
743 saddr.sun_path, strerror(errno)); | 748 saddr.sun_path, strerror(errno)); |
744 g_log(NULL, G_LOG_LEVEL_CRITICAL, | 749 g_log(NULL, G_LOG_LEVEL_CRITICAL, |
745 "Failed to assign %s to a socket (Error: %s)", | 750 "Failed to assign %s to a socket (Error: %s)", |
746 saddr.sun_path, strerror(errno)); | 751 saddr.sun_path, strerror(errno)); |
747 umask(m); | 752 umask(m); |
748 return -1; | 753 return -1; |
749 } | 754 } |
750 umask(m); | 755 umask(m); |