Mercurial > pidgin
comparison libpurple/protocols/sametime/sametime.c @ 32819:2c6510167895 default tip
propagate from branch 'im.pidgin.pidgin.2.x.y' (head 3315c5dfbd0ad16511bdcf865e5b07c02d07df24)
to branch 'im.pidgin.pidgin' (head cbd1eda6bcbf0565ae7766396bb8f6f419cb6a9a)
| author | Elliott Sales de Andrade <qulogic@pidgin.im> |
|---|---|
| date | Sat, 02 Jun 2012 02:30:49 +0000 |
| parents | 0a043c8747c5 |
| children |
comparison
equal
deleted
inserted
replaced
| 32818:01ff09d4a463 | 32819:2c6510167895 |
|---|---|
| 195 /** handler IDs from g_log_set_handler in mw_plugin_init */ | 195 /** handler IDs from g_log_set_handler in mw_plugin_init */ |
| 196 static guint log_handler[2] = { 0, 0 }; | 196 static guint log_handler[2] = { 0, 0 }; |
| 197 | 197 |
| 198 | 198 |
| 199 /** the purple plugin data. | 199 /** the purple plugin data. |
| 200 available as gc->proto_data and mwSession_getClientData */ | 200 available as purple_connection_get_protocol_data(gc) and mwSession_getClientData */ |
| 201 struct mwPurplePluginData { | 201 struct mwPurplePluginData { |
| 202 struct mwSession *session; | 202 struct mwSession *session; |
| 203 | 203 |
| 204 struct mwServiceAware *srvc_aware; | 204 struct mwServiceAware *srvc_aware; |
| 205 struct mwServiceConference *srvc_conf; | 205 struct mwServiceConference *srvc_conf; |
| 215 /** event id for the buddy list save callback */ | 215 /** event id for the buddy list save callback */ |
| 216 guint save_event; | 216 guint save_event; |
| 217 | 217 |
| 218 /** socket fd */ | 218 /** socket fd */ |
| 219 int socket; | 219 int socket; |
| 220 guint inpa; /* input watcher */ | |
| 220 gint outpa; /* like inpa, but the other way */ | 221 gint outpa; /* like inpa, but the other way */ |
| 221 | 222 |
| 222 /** circular buffer for outgoing data */ | 223 /** circular buffer for outgoing data */ |
| 223 PurpleCircBuffer *sock_buf; | 224 PurpleCircBuffer *sock_buf; |
| 224 | 225 |
| 318 static struct mwSession *gc_to_session(PurpleConnection *gc) { | 319 static struct mwSession *gc_to_session(PurpleConnection *gc) { |
| 319 struct mwPurplePluginData *pd; | 320 struct mwPurplePluginData *pd; |
| 320 | 321 |
| 321 g_return_val_if_fail(gc != NULL, NULL); | 322 g_return_val_if_fail(gc != NULL, NULL); |
| 322 | 323 |
| 323 pd = gc->proto_data; | 324 pd = purple_connection_get_protocol_data(gc); |
| 324 g_return_val_if_fail(pd != NULL, NULL); | 325 g_return_val_if_fail(pd != NULL, NULL); |
| 325 | 326 |
| 326 return pd->session; | 327 return pd->session; |
| 327 } | 328 } |
| 328 | 329 |
| 411 } else if(len > 0) { | 412 } else if(len > 0) { |
| 412 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), | 413 gchar *tmp = g_strdup_printf(_("Lost connection with server: %s"), |
| 413 g_strerror(errno)); | 414 g_strerror(errno)); |
| 414 DEBUG_ERROR("write returned %" G_GSSIZE_FORMAT ", %" G_GSIZE_FORMAT | 415 DEBUG_ERROR("write returned %" G_GSSIZE_FORMAT ", %" G_GSIZE_FORMAT |
| 415 " bytes left unwritten\n", ret, len); | 416 " bytes left unwritten\n", ret, len); |
| 416 purple_connection_error_reason(pd->gc, | 417 purple_connection_error(pd->gc, |
| 417 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 418 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 418 tmp); | 419 tmp); |
| 419 g_free(tmp); | 420 g_free(tmp); |
| 420 | 421 |
| 421 #if 0 | 422 #if 0 |
| 447 if(pd->socket) { | 448 if(pd->socket) { |
| 448 close(pd->socket); | 449 close(pd->socket); |
| 449 pd->socket = 0; | 450 pd->socket = 0; |
| 450 } | 451 } |
| 451 | 452 |
| 452 if(gc->inpa) { | 453 if(pd->inpa) { |
| 453 purple_input_remove(gc->inpa); | 454 purple_input_remove(pd->inpa); |
| 454 gc->inpa = 0; | 455 pd->inpa = 0; |
| 455 } | 456 } |
| 456 } | 457 } |
| 457 | 458 |
| 458 | 459 |
| 459 static void mw_session_clear(struct mwSession *session) { | 460 static void mw_session_clear(struct mwSession *session) { |
| 497 const char *status = MW_STATE_ACTIVE; | 498 const char *status = MW_STATE_ACTIVE; |
| 498 | 499 |
| 499 gc = mwAwareList_getClientData(list); | 500 gc = mwAwareList_getClientData(list); |
| 500 acct = purple_connection_get_account(gc); | 501 acct = purple_connection_get_account(gc); |
| 501 | 502 |
| 502 pd = gc->proto_data; | 503 pd = purple_connection_get_protocol_data(gc); |
| 503 idle = aware->status.time; | 504 idle = aware->status.time; |
| 504 stat = aware->status.status; | 505 stat = aware->status.status; |
| 505 id = aware->id.user; | 506 id = aware->id.user; |
| 506 | 507 |
| 507 if(idle) { | 508 if(idle) { |
| 849 /** ensure that a PurpleBuddy exists in the group with data | 850 /** ensure that a PurpleBuddy exists in the group with data |
| 850 appropriately matching the st user entry from the st list */ | 851 appropriately matching the st user entry from the st list */ |
| 851 static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, | 852 static PurpleBuddy *buddy_ensure(PurpleConnection *gc, PurpleGroup *group, |
| 852 struct mwSametimeUser *stuser) { | 853 struct mwSametimeUser *stuser) { |
| 853 | 854 |
| 854 struct mwPurplePluginData *pd = gc->proto_data; | 855 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 855 PurpleBuddy *buddy; | 856 PurpleBuddy *buddy; |
| 856 PurpleAccount *acct = purple_connection_get_account(gc); | 857 PurpleAccount *acct = purple_connection_get_account(gc); |
| 857 | 858 |
| 858 const char *id = mwSametimeUser_getUser(stuser); | 859 const char *id = mwSametimeUser_getUser(stuser); |
| 859 const char *name = mwSametimeUser_getShortName(stuser); | 860 const char *name = mwSametimeUser_getShortName(stuser); |
| 860 const char *alias = mwSametimeUser_getAlias(stuser); | 861 const char *alias = mwSametimeUser_getAlias(stuser); |
| 861 enum mwSametimeUserType type = mwSametimeUser_getType(stuser); | 862 enum mwSametimeUserType type = mwSametimeUser_getType(stuser); |
| 862 | 863 |
| 863 g_return_val_if_fail(id != NULL, NULL); | 864 g_return_val_if_fail(id != NULL, NULL); |
| 864 g_return_val_if_fail(strlen(id) > 0, NULL); | 865 g_return_val_if_fail(*id, NULL); |
| 865 | 866 |
| 866 buddy = purple_find_buddy_in_group(acct, id, group); | 867 buddy = purple_find_buddy_in_group(acct, id, group); |
| 867 if(! buddy) { | 868 if(! buddy) { |
| 868 buddy = purple_buddy_new(acct, id, alias); | 869 buddy = purple_buddy_new(acct, id, alias); |
| 869 | 870 |
| 971 purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); | 972 purple_blist_node_set_string(gn, GROUP_KEY_NAME, name); |
| 972 purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); | 973 purple_blist_node_set_int(gn, GROUP_KEY_TYPE, type); |
| 973 | 974 |
| 974 if(type == mwSametimeGroup_DYNAMIC) { | 975 if(type == mwSametimeGroup_DYNAMIC) { |
| 975 purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); | 976 purple_blist_node_set_string(gn, GROUP_KEY_OWNER, owner); |
| 976 group_add(gc->proto_data, group); | 977 group_add(purple_connection_get_protocol_data(gc), group); |
| 977 } | 978 } |
| 978 | 979 |
| 979 return group; | 980 return group; |
| 980 } | 981 } |
| 981 | 982 |
| 1277 | 1278 |
| 1278 PurpleConnection *gc; | 1279 PurpleConnection *gc; |
| 1279 struct mwIdBlock who = { 0, 0 }; | 1280 struct mwIdBlock who = { 0, 0 }; |
| 1280 struct mwConversation *conv; | 1281 struct mwConversation *conv; |
| 1281 | 1282 |
| 1282 gc = purple_conversation_get_gc(g_conv); | 1283 gc = purple_conversation_get_connection(g_conv); |
| 1283 if(pd->gc != gc) | 1284 if(pd->gc != gc) |
| 1284 return; /* not ours */ | 1285 return; /* not ours */ |
| 1285 | 1286 |
| 1286 if(purple_conversation_get_type(g_conv) != PURPLE_CONV_TYPE_IM) | 1287 if(purple_conversation_get_type(g_conv) != PURPLE_CONV_TYPE_IM) |
| 1287 return; /* wrong type */ | 1288 return; /* wrong type */ |
| 1401 } | 1402 } |
| 1402 } | 1403 } |
| 1403 } | 1404 } |
| 1404 | 1405 |
| 1405 if(add_buds) { | 1406 if(add_buds) { |
| 1406 purple_account_add_buddies(acct, add_buds); | 1407 purple_account_add_buddies(acct, add_buds, NULL); |
| 1407 g_list_free(add_buds); | 1408 g_list_free(add_buds); |
| 1408 } | 1409 } |
| 1409 } | 1410 } |
| 1410 | 1411 |
| 1411 | 1412 |
| 1616 break; | 1617 break; |
| 1617 | 1618 |
| 1618 default: | 1619 default: |
| 1619 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; | 1620 reason = PURPLE_CONNECTION_ERROR_NETWORK_ERROR; |
| 1620 } | 1621 } |
| 1621 purple_connection_error_reason(gc, reason, err); | 1622 purple_connection_error(gc, reason, err); |
| 1622 g_free(err); | 1623 g_free(err); |
| 1623 } | 1624 } |
| 1624 break; | 1625 break; |
| 1625 | 1626 |
| 1626 case mwSession_STOPPED: | 1627 case mwSession_STOPPED: |
| 1758 if(pd->socket) { | 1759 if(pd->socket) { |
| 1759 close(pd->socket); | 1760 close(pd->socket); |
| 1760 pd->socket = 0; | 1761 pd->socket = 0; |
| 1761 } | 1762 } |
| 1762 | 1763 |
| 1763 if(pd->gc->inpa) { | 1764 if(pd->inpa) { |
| 1764 purple_input_remove(pd->gc->inpa); | 1765 purple_input_remove(pd->inpa); |
| 1765 pd->gc->inpa = 0; | 1766 pd->inpa = 0; |
| 1766 } | 1767 } |
| 1767 | 1768 |
| 1768 if(! ret) { | 1769 if(! ret) { |
| 1769 DEBUG_INFO("connection reset\n"); | 1770 DEBUG_INFO("connection reset\n"); |
| 1770 purple_connection_error_reason(pd->gc, | 1771 purple_connection_error(pd->gc, |
| 1771 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 1772 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1772 _("Server closed the connection")); | 1773 _("Server closed the connection")); |
| 1773 | 1774 |
| 1774 } else if(ret < 0) { | 1775 } else if(ret < 0) { |
| 1775 const gchar *err_str = g_strerror(err); | 1776 const gchar *err_str = g_strerror(err); |
| 1776 char *msg = NULL; | 1777 char *msg = NULL; |
| 1777 | 1778 |
| 1778 DEBUG_INFO("error in read callback: %s\n", err_str); | 1779 DEBUG_INFO("error in read callback: %s\n", err_str); |
| 1779 | 1780 |
| 1780 msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); | 1781 msg = g_strdup_printf(_("Lost connection with server: %s"), err_str); |
| 1781 purple_connection_error_reason(pd->gc, | 1782 purple_connection_error(pd->gc, |
| 1782 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 1783 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1783 msg); | 1784 msg); |
| 1784 g_free(msg); | 1785 g_free(msg); |
| 1785 } | 1786 } |
| 1786 } | 1787 } |
| 1789 /** Callback passed to purple_proxy_connect when an account is logged | 1790 /** Callback passed to purple_proxy_connect when an account is logged |
| 1790 in, and if the session logging in receives a redirect message */ | 1791 in, and if the session logging in receives a redirect message */ |
| 1791 static void connect_cb(gpointer data, gint source, const gchar *error_message) { | 1792 static void connect_cb(gpointer data, gint source, const gchar *error_message) { |
| 1792 | 1793 |
| 1793 struct mwPurplePluginData *pd = data; | 1794 struct mwPurplePluginData *pd = data; |
| 1794 PurpleConnection *gc = pd->gc; | |
| 1795 | 1795 |
| 1796 if(source < 0) { | 1796 if(source < 0) { |
| 1797 /* connection failed */ | 1797 /* connection failed */ |
| 1798 | 1798 |
| 1799 if(pd->socket) { | 1799 if(pd->socket) { |
| 1802 | 1802 |
| 1803 } else { | 1803 } else { |
| 1804 /* this is a regular connect, error out */ | 1804 /* this is a regular connect, error out */ |
| 1805 gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), | 1805 gchar *tmp = g_strdup_printf(_("Unable to connect: %s"), |
| 1806 error_message); | 1806 error_message); |
| 1807 purple_connection_error_reason(pd->gc, | 1807 purple_connection_error(pd->gc, |
| 1808 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 1808 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 1809 tmp); | 1809 tmp); |
| 1810 g_free(tmp); | 1810 g_free(tmp); |
| 1811 } | 1811 } |
| 1812 | 1812 |
| 1817 /* stop any existing login attempt */ | 1817 /* stop any existing login attempt */ |
| 1818 mwSession_stop(pd->session, ERR_SUCCESS); | 1818 mwSession_stop(pd->session, ERR_SUCCESS); |
| 1819 } | 1819 } |
| 1820 | 1820 |
| 1821 pd->socket = source; | 1821 pd->socket = source; |
| 1822 gc->inpa = purple_input_add(source, PURPLE_INPUT_READ, | 1822 pd->inpa = purple_input_add(source, PURPLE_INPUT_READ, |
| 1823 read_cb, pd); | 1823 read_cb, pd); |
| 1824 | 1824 |
| 1825 mwSession_start(pd->session); | 1825 mwSession_start(pd->session); |
| 1826 } | 1826 } |
| 1827 | 1827 |
| 2142 #define MW_FT_LEN (BUF_LONG * 2) | 2142 #define MW_FT_LEN (BUF_LONG * 2) |
| 2143 | 2143 |
| 2144 | 2144 |
| 2145 static void ft_incoming_cancel(PurpleXfer *xfer) { | 2145 static void ft_incoming_cancel(PurpleXfer *xfer) { |
| 2146 /* incoming transfer rejected or cancelled in-progress */ | 2146 /* incoming transfer rejected or cancelled in-progress */ |
| 2147 struct mwFileTransfer *ft = xfer->data; | 2147 struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 2148 if(ft) mwFileTransfer_reject(ft); | 2148 if(ft) mwFileTransfer_reject(ft); |
| 2149 } | 2149 } |
| 2150 | 2150 |
| 2151 | 2151 |
| 2152 static void ft_incoming_init(PurpleXfer *xfer) { | 2152 static void ft_incoming_init(PurpleXfer *xfer) { |
| 2158 */ | 2158 */ |
| 2159 | 2159 |
| 2160 struct mwFileTransfer *ft; | 2160 struct mwFileTransfer *ft; |
| 2161 FILE *fp; | 2161 FILE *fp; |
| 2162 | 2162 |
| 2163 ft = xfer->data; | 2163 ft = purple_xfer_get_protocol_data(xfer); |
| 2164 | 2164 |
| 2165 fp = g_fopen(xfer->local_filename, "wb"); | 2165 fp = g_fopen(purple_xfer_get_local_filename(xfer), "wb"); |
| 2166 if(! fp) { | 2166 if(! fp) { |
| 2167 mwFileTransfer_cancel(ft); | 2167 mwFileTransfer_cancel(ft); |
| 2168 return; | 2168 return; |
| 2169 } | 2169 } |
| 2170 | 2170 |
| 2205 xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); | 2205 xfer = purple_xfer_new(acct, PURPLE_XFER_RECEIVE, who); |
| 2206 if (xfer) | 2206 if (xfer) |
| 2207 { | 2207 { |
| 2208 purple_xfer_ref(xfer); | 2208 purple_xfer_ref(xfer); |
| 2209 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | 2209 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); |
| 2210 xfer->data = ft; | 2210 purple_xfer_set_protocol_data(xfer, ft); |
| 2211 | 2211 |
| 2212 purple_xfer_set_init_fnc(xfer, ft_incoming_init); | 2212 purple_xfer_set_init_fnc(xfer, ft_incoming_init); |
| 2213 purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); | 2213 purple_xfer_set_cancel_recv_fnc(xfer, ft_incoming_cancel); |
| 2214 purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); | 2214 purple_xfer_set_request_denied_fnc(xfer, ft_incoming_cancel); |
| 2215 | 2215 |
| 2234 if(rem < MW_FT_LEN) o.len = rem; | 2234 if(rem < MW_FT_LEN) o.len = rem; |
| 2235 | 2235 |
| 2236 if(fread(buf, (size_t) o.len, 1, fp)) { | 2236 if(fread(buf, (size_t) o.len, 1, fp)) { |
| 2237 | 2237 |
| 2238 /* calculate progress and display it */ | 2238 /* calculate progress and display it */ |
| 2239 xfer->bytes_sent += o.len; | 2239 purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + o.len); |
| 2240 xfer->bytes_remaining -= o.len; | |
| 2241 purple_xfer_update_progress(xfer); | 2240 purple_xfer_update_progress(xfer); |
| 2242 | 2241 |
| 2243 mwFileTransfer_send(ft, &o); | 2242 mwFileTransfer_send(ft, &o); |
| 2244 | 2243 |
| 2245 } else { | 2244 } else { |
| 2267 mwFileTransfer_free(ft); | 2266 mwFileTransfer_free(ft); |
| 2268 g_return_if_reached(); | 2267 g_return_if_reached(); |
| 2269 } | 2268 } |
| 2270 | 2269 |
| 2271 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { | 2270 if(purple_xfer_get_type(xfer) == PURPLE_XFER_SEND) { |
| 2272 xfer->dest_fp = g_fopen(xfer->local_filename, "rb"); | 2271 xfer->dest_fp = g_fopen(purple_xfer_get_local_filename(xfer), "rb"); |
| 2273 ft_send(ft, xfer->dest_fp); | 2272 ft_send(ft, xfer->dest_fp); |
| 2274 } | 2273 } |
| 2275 } | 2274 } |
| 2276 | 2275 |
| 2277 | 2276 |
| 2284 | 2283 |
| 2285 PurpleXfer *xfer; | 2284 PurpleXfer *xfer; |
| 2286 | 2285 |
| 2287 xfer = mwFileTransfer_getClientData(ft); | 2286 xfer = mwFileTransfer_getClientData(ft); |
| 2288 if(xfer) { | 2287 if(xfer) { |
| 2289 xfer->data = NULL; | 2288 purple_xfer_set_protocol_data(xfer, NULL); |
| 2290 | 2289 |
| 2291 if(! mwFileTransfer_getRemaining(ft)) { | 2290 if(! mwFileTransfer_getRemaining(ft)) { |
| 2292 purple_xfer_set_completed(xfer, TRUE); | 2291 purple_xfer_set_completed(xfer, TRUE); |
| 2293 purple_xfer_end(xfer); | 2292 purple_xfer_end(xfer); |
| 2294 | 2293 |
| 2337 purple_xfer_cancel_local(xfer); | 2336 purple_xfer_cancel_local(xfer); |
| 2338 return; | 2337 return; |
| 2339 } | 2338 } |
| 2340 | 2339 |
| 2341 /* update the progress */ | 2340 /* update the progress */ |
| 2342 xfer->bytes_sent += data->len; | 2341 purple_xfer_set_bytes_sent(xfer, purple_xfer_get_bytes_sent(xfer) + data->len); |
| 2343 xfer->bytes_remaining -= data->len; | |
| 2344 purple_xfer_update_progress(xfer); | 2342 purple_xfer_update_progress(xfer); |
| 2345 | 2343 |
| 2346 /* let the other side know we got it, and to send some more */ | 2344 /* let the other side know we got it, and to send some more */ |
| 2347 mwFileTransfer_ack(ft); | 2345 mwFileTransfer_ack(ft); |
| 2348 } | 2346 } |
| 2351 static void mw_ft_ack(struct mwFileTransfer *ft) { | 2349 static void mw_ft_ack(struct mwFileTransfer *ft) { |
| 2352 PurpleXfer *xfer; | 2350 PurpleXfer *xfer; |
| 2353 | 2351 |
| 2354 xfer = mwFileTransfer_getClientData(ft); | 2352 xfer = mwFileTransfer_getClientData(ft); |
| 2355 g_return_if_fail(xfer != NULL); | 2353 g_return_if_fail(xfer != NULL); |
| 2356 g_return_if_fail(xfer->watcher == 0); | 2354 g_return_if_fail(purple_xfer_get_watcher(xfer) == 0); |
| 2357 | 2355 |
| 2358 if(! mwFileTransfer_getRemaining(ft)) { | 2356 if(! mwFileTransfer_getRemaining(ft)) { |
| 2359 purple_xfer_set_completed(xfer, TRUE); | 2357 purple_xfer_set_completed(xfer, TRUE); |
| 2360 purple_xfer_end(xfer); | 2358 purple_xfer_end(xfer); |
| 2361 | 2359 |
| 2485 | 2483 |
| 2486 tmp = mwError(err); | 2484 tmp = mwError(err); |
| 2487 text = g_strconcat(_("Unable to send message: "), tmp, NULL); | 2485 text = g_strconcat(_("Unable to send message: "), tmp, NULL); |
| 2488 | 2486 |
| 2489 gconv = convo_get_gconv(conv); | 2487 gconv = convo_get_gconv(conv); |
| 2490 if(gconv && !purple_conv_present_error(idb->user, gconv->account, text)) { | 2488 if(gconv && !purple_conv_present_error(idb->user, purple_conversation_get_account(gconv), text)) { |
| 2491 | 2489 |
| 2492 g_free(text); | 2490 g_free(text); |
| 2493 text = g_strdup_printf(_("Unable to send message to %s:"), | 2491 text = g_strdup_printf(_("Unable to send message to %s:"), |
| 2494 (idb->user)? idb->user: "(unknown)"); | 2492 (idb->user)? idb->user: "(unknown)"); |
| 2495 purple_notify_error(purple_account_get_connection(gconv->account), | 2493 purple_notify_error(purple_account_get_connection(purple_conversation_get_account(gconv)), |
| 2496 NULL, text, tmp); | 2494 NULL, text, tmp); |
| 2497 } | 2495 } |
| 2498 | 2496 |
| 2499 g_free(tmp); | 2497 g_free(tmp); |
| 2500 g_free(text); | 2498 g_free(text); |
| 2528 PurpleConnection *gc; | 2526 PurpleConnection *gc; |
| 2529 | 2527 |
| 2530 gconv = convo_get_gconv(conv); | 2528 gconv = convo_get_gconv(conv); |
| 2531 if(! gconv) return; | 2529 if(! gconv) return; |
| 2532 | 2530 |
| 2533 gc = purple_conversation_get_gc(gconv); | 2531 gc = purple_conversation_get_connection(gconv); |
| 2534 if(! gc) return; | 2532 if(! gc) return; |
| 2535 | 2533 |
| 2536 purple_conversation_set_features(gconv, gc->flags); | 2534 purple_conversation_set_features(gconv, purple_connection_get_flags(gc)); |
| 2537 } | 2535 } |
| 2538 | 2536 |
| 2539 | 2537 |
| 2540 /** called when a mw conversation and purple conversation come together, | 2538 /** called when a mw conversation and purple conversation come together, |
| 2541 to inform the purple conversation of what features to offer the | 2539 to inform the purple conversation of what features to offer the |
| 3197 | 3195 |
| 3198 mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session)); | 3196 mwSession_addCipher(pd->session, mwCipher_new_RC2_40(pd->session)); |
| 3199 mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); | 3197 mwSession_addCipher(pd->session, mwCipher_new_RC2_128(pd->session)); |
| 3200 | 3198 |
| 3201 mwSession_setClientData(pd->session, pd, NULL); | 3199 mwSession_setClientData(pd->session, pd, NULL); |
| 3202 gc->proto_data = pd; | 3200 purple_connection_set_protocol_data(gc, pd); |
| 3203 | 3201 |
| 3204 return pd; | 3202 return pd; |
| 3205 } | 3203 } |
| 3206 | 3204 |
| 3207 | 3205 |
| 3208 static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { | 3206 static void mwPurplePluginData_free(struct mwPurplePluginData *pd) { |
| 3209 g_return_if_fail(pd != NULL); | 3207 g_return_if_fail(pd != NULL); |
| 3210 | 3208 |
| 3211 pd->gc->proto_data = NULL; | 3209 purple_connection_set_protocol_data(pd->gc, NULL); |
| 3212 | 3210 |
| 3213 mwSession_removeService(pd->session, mwService_AWARE); | 3211 mwSession_removeService(pd->session, mwService_AWARE); |
| 3214 mwSession_removeService(pd->session, mwService_CONFERENCE); | 3212 mwSession_removeService(pd->session, mwService_CONFERENCE); |
| 3215 mwSession_removeService(pd->session, mwService_FILE_TRANSFER); | 3213 mwSession_removeService(pd->session, mwService_FILE_TRANSFER); |
| 3216 mwSession_removeService(pd->session, mwService_IM); | 3214 mwSession_removeService(pd->session, mwService_IM); |
| 3268 struct mwPurplePluginData *pd; | 3266 struct mwPurplePluginData *pd; |
| 3269 struct mwAwareIdBlock t = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; | 3267 struct mwAwareIdBlock t = { mwAware_USER, (char *)purple_buddy_get_name(b), NULL }; |
| 3270 const char *ret = NULL; | 3268 const char *ret = NULL; |
| 3271 | 3269 |
| 3272 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) | 3270 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
| 3273 && (pd = gc->proto_data)) | 3271 && (pd = purple_connection_get_protocol_data(gc))) |
| 3274 ret = mwServiceAware_getText(pd->srvc_aware, &t); | 3272 ret = mwServiceAware_getText(pd->srvc_aware, &t); |
| 3275 | 3273 |
| 3276 return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; | 3274 return (ret && g_utf8_validate(ret, -1, NULL)) ? g_markup_escape_text(ret, -1): NULL; |
| 3277 } | 3275 } |
| 3278 | 3276 |
| 3331 const char *message = NULL; | 3329 const char *message = NULL; |
| 3332 const char *status; | 3330 const char *status; |
| 3333 char *tmp; | 3331 char *tmp; |
| 3334 | 3332 |
| 3335 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) | 3333 if ((gc = purple_account_get_connection(purple_buddy_get_account(b))) |
| 3336 && (pd = gc->proto_data)) | 3334 && (pd = purple_connection_get_protocol_data(gc))) |
| 3337 message = mwServiceAware_getText(pd->srvc_aware, &idb); | 3335 message = mwServiceAware_getText(pd->srvc_aware, &idb); |
| 3338 | 3336 |
| 3339 status = status_text(b); | 3337 status = status_text(b); |
| 3340 | 3338 |
| 3341 if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { | 3339 if(message != NULL && g_utf8_validate(message, -1, NULL) && purple_utf8_strcasecmp(status, message)) { |
| 3342 tmp = g_markup_escape_text(message, -1); | 3340 purple_notify_user_info_add_pair_plaintext(user_info, status, message); |
| 3343 purple_notify_user_info_add_pair(user_info, status, tmp); | |
| 3344 g_free(tmp); | |
| 3345 | 3341 |
| 3346 } else { | 3342 } else { |
| 3347 purple_notify_user_info_add_pair(user_info, _("Status"), status); | 3343 purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status); |
| 3348 } | 3344 } |
| 3349 | 3345 |
| 3350 if(full && pd != NULL) { | 3346 if(full && pd != NULL) { |
| 3351 tmp = user_supports_text(pd->srvc_aware, purple_buddy_get_name(b)); | 3347 tmp = user_supports_text(pd->srvc_aware, purple_buddy_get_name(b)); |
| 3352 if(tmp) { | 3348 if(tmp) { |
| 3353 purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); | 3349 purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
| 3354 g_free(tmp); | 3350 g_free(tmp); |
| 3355 } | 3351 } |
| 3356 | 3352 |
| 3357 if(buddy_is_external(b)) { | 3353 if(buddy_is_external(b)) { |
| 3358 purple_notify_user_info_add_pair(user_info, NULL, _("External User")); | 3354 purple_notify_user_info_add_pair_plaintext(user_info, NULL, _("External User")); |
| 3359 } | 3355 } |
| 3360 } | 3356 } |
| 3361 } | 3357 } |
| 3362 | 3358 |
| 3363 static GList *mw_prpl_status_types(PurpleAccount *acct) | 3359 static GList *mw_prpl_status_types(PurpleAccount *acct) |
| 3410 struct mwConference *conf; | 3406 struct mwConference *conf; |
| 3411 struct mwIdBlock idb = { NULL, NULL }; | 3407 struct mwIdBlock idb = { NULL, NULL }; |
| 3412 | 3408 |
| 3413 acct = purple_buddy_get_account(buddy); | 3409 acct = purple_buddy_get_account(buddy); |
| 3414 gc = purple_account_get_connection(acct); | 3410 gc = purple_account_get_connection(acct); |
| 3415 pd = gc->proto_data; | 3411 pd = purple_connection_get_protocol_data(gc); |
| 3416 srvc = pd->srvc_conf; | 3412 srvc = pd->srvc_conf; |
| 3417 | 3413 |
| 3418 f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); | 3414 f = purple_request_fields_get_field(fields, CHAT_KEY_TOPIC); |
| 3419 topic = purple_request_field_string_get_value(f); | 3415 topic = purple_request_field_string_get_value(f); |
| 3420 | 3416 |
| 3576 g_return_if_fail(acct != NULL); | 3572 g_return_if_fail(acct != NULL); |
| 3577 | 3573 |
| 3578 gc = purple_account_get_connection(acct); | 3574 gc = purple_account_get_connection(acct); |
| 3579 g_return_if_fail(gc != NULL); | 3575 g_return_if_fail(gc != NULL); |
| 3580 | 3576 |
| 3581 pd = gc->proto_data; | 3577 pd = purple_connection_get_protocol_data(gc); |
| 3582 g_return_if_fail(pd != NULL); | 3578 g_return_if_fail(pd != NULL); |
| 3583 | 3579 |
| 3584 /* | 3580 /* |
| 3585 - get a list of all conferences on this session | 3581 - get a list of all conferences on this session |
| 3586 - if none, prompt to create one, and invite buddy to it | 3582 - if none, prompt to create one, and invite buddy to it |
| 3615 g_return_if_fail(acct != NULL); | 3611 g_return_if_fail(acct != NULL); |
| 3616 | 3612 |
| 3617 gc = purple_account_get_connection(acct); | 3613 gc = purple_account_get_connection(acct); |
| 3618 g_return_if_fail(gc != NULL); | 3614 g_return_if_fail(gc != NULL); |
| 3619 | 3615 |
| 3620 pd = gc->proto_data; | 3616 pd = purple_connection_get_protocol_data(gc); |
| 3621 g_return_if_fail(pd != NULL); | 3617 g_return_if_fail(pd != NULL); |
| 3622 | 3618 |
| 3623 rcpt_name = g_strdup_printf("@U %s", buddy->name); | 3619 rcpt_name = g_strdup_printf("@U %s", buddy->name); |
| 3624 rcpt = g_list_prepend(NULL, rcpt_name); | 3620 rcpt = g_list_prepend(NULL, rcpt_name); |
| 3625 | 3621 |
| 3703 | 3699 |
| 3704 gc = purple_account_get_connection(account); | 3700 gc = purple_account_get_connection(account); |
| 3705 pd = mwPurplePluginData_new(gc); | 3701 pd = mwPurplePluginData_new(gc); |
| 3706 | 3702 |
| 3707 /* while we do support images, the default is to not offer it */ | 3703 /* while we do support images, the default is to not offer it */ |
| 3708 gc->flags |= PURPLE_CONNECTION_NO_IMAGES; | 3704 purple_connection_set_flags(gc, PURPLE_CONNECTION_NO_IMAGES); |
| 3709 | 3705 |
| 3710 user = g_strdup(purple_account_get_username(account)); | 3706 user = g_strdup(purple_account_get_username(account)); |
| 3711 | 3707 |
| 3712 host = strrchr(user, ':'); | 3708 host = strrchr(user, ':'); |
| 3713 if(host) { | 3709 if(host) { |
| 3723 | 3719 |
| 3724 if(! host || ! *host) { | 3720 if(! host || ! *host) { |
| 3725 /* somehow, we don't have a host to connect to. Well, we need one | 3721 /* somehow, we don't have a host to connect to. Well, we need one |
| 3726 to actually continue, so let's ask the user directly. */ | 3722 to actually continue, so let's ask the user directly. */ |
| 3727 g_free(user); | 3723 g_free(user); |
| 3728 purple_connection_error_reason(gc, | 3724 purple_connection_error(gc, |
| 3729 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, | 3725 PURPLE_CONNECTION_ERROR_INVALID_SETTINGS, |
| 3730 _("A server is required to connect this account")); | 3726 _("A server is required to connect this account")); |
| 3731 return; | 3727 return; |
| 3732 } | 3728 } |
| 3733 | 3729 |
| 3768 } | 3764 } |
| 3769 | 3765 |
| 3770 purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); | 3766 purple_connection_update_progress(gc, _("Connecting"), 1, MW_CONNECT_STEPS); |
| 3771 | 3767 |
| 3772 if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { | 3768 if (purple_proxy_connect(gc, account, host, port, connect_cb, pd) == NULL) { |
| 3773 purple_connection_error_reason(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, | 3769 purple_connection_error(gc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR, |
| 3774 _("Unable to connect")); | 3770 _("Unable to connect")); |
| 3775 } | 3771 } |
| 3776 } | 3772 } |
| 3777 | 3773 |
| 3778 | 3774 |
| 3779 static void mw_prpl_close(PurpleConnection *gc) { | 3775 static void mw_prpl_close(PurpleConnection *gc) { |
| 3780 struct mwPurplePluginData *pd; | 3776 struct mwPurplePluginData *pd; |
| 3781 | 3777 |
| 3782 g_return_if_fail(gc != NULL); | 3778 g_return_if_fail(gc != NULL); |
| 3783 | 3779 |
| 3784 pd = gc->proto_data; | 3780 pd = purple_connection_get_protocol_data(gc); |
| 3785 g_return_if_fail(pd != NULL); | 3781 g_return_if_fail(pd != NULL); |
| 3786 | 3782 |
| 3787 /* get rid of the blist save timeout */ | 3783 /* get rid of the blist save timeout */ |
| 3788 if(pd->save_event) { | 3784 if(pd->save_event) { |
| 3789 purple_timeout_remove(pd->save_event); | 3785 purple_timeout_remove(pd->save_event); |
| 3793 | 3789 |
| 3794 /* stop the session */ | 3790 /* stop the session */ |
| 3795 mwSession_stop(pd->session, 0x00); | 3791 mwSession_stop(pd->session, 0x00); |
| 3796 | 3792 |
| 3797 /* no longer necessary */ | 3793 /* no longer necessary */ |
| 3798 gc->proto_data = NULL; | 3794 purple_connection_set_protocol_data(gc, NULL); |
| 3799 | 3795 |
| 3800 /* stop watching the socket */ | 3796 /* stop watching the socket */ |
| 3801 if(gc->inpa) { | 3797 if(pd->inpa) { |
| 3802 purple_input_remove(gc->inpa); | 3798 purple_input_remove(pd->inpa); |
| 3803 gc->inpa = 0; | 3799 pd->inpa = 0; |
| 3804 } | 3800 } |
| 3805 | 3801 |
| 3806 /* clean up the rest */ | 3802 /* clean up the rest */ |
| 3807 mwPurplePluginData_free(pd); | 3803 mwPurplePluginData_free(pd); |
| 3808 } | 3804 } |
| 3984 struct mwPurplePluginData *pd; | 3980 struct mwPurplePluginData *pd; |
| 3985 struct mwIdBlock who = { (char *) name, NULL }; | 3981 struct mwIdBlock who = { (char *) name, NULL }; |
| 3986 struct mwConversation *conv; | 3982 struct mwConversation *conv; |
| 3987 | 3983 |
| 3988 g_return_val_if_fail(gc != NULL, 0); | 3984 g_return_val_if_fail(gc != NULL, 0); |
| 3989 pd = gc->proto_data; | 3985 pd = purple_connection_get_protocol_data(gc); |
| 3990 | 3986 |
| 3991 g_return_val_if_fail(pd != NULL, 0); | 3987 g_return_val_if_fail(pd != NULL, 0); |
| 3992 | 3988 |
| 3993 conv = mwServiceIm_getConversation(pd->srvc_im, &who); | 3989 conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 3994 | 3990 |
| 4059 struct mwConversation *conv; | 4055 struct mwConversation *conv; |
| 4060 | 4056 |
| 4061 gpointer t = GINT_TO_POINTER(!! state); | 4057 gpointer t = GINT_TO_POINTER(!! state); |
| 4062 | 4058 |
| 4063 g_return_val_if_fail(gc != NULL, 0); | 4059 g_return_val_if_fail(gc != NULL, 0); |
| 4064 pd = gc->proto_data; | 4060 pd = purple_connection_get_protocol_data(gc); |
| 4065 | 4061 |
| 4066 g_return_val_if_fail(pd != NULL, 0); | 4062 g_return_val_if_fail(pd != NULL, 0); |
| 4067 | 4063 |
| 4068 conv = mwServiceIm_getConversation(pd->srvc_im, &who); | 4064 conv = mwServiceIm_getConversation(pd->srvc_im, &who); |
| 4069 | 4065 |
| 4155 const char *tmp2; | 4151 const char *tmp2; |
| 4156 | 4152 |
| 4157 g_return_if_fail(who != NULL); | 4153 g_return_if_fail(who != NULL); |
| 4158 g_return_if_fail(*who != '\0'); | 4154 g_return_if_fail(*who != '\0'); |
| 4159 | 4155 |
| 4160 pd = gc->proto_data; | 4156 pd = purple_connection_get_protocol_data(gc); |
| 4161 | 4157 |
| 4162 acct = purple_connection_get_account(gc); | 4158 acct = purple_connection_get_account(gc); |
| 4163 b = purple_find_buddy(acct, who); | 4159 b = purple_find_buddy(acct, who); |
| 4164 user_info = purple_notify_user_info_new(); | 4160 user_info = purple_notify_user_info_new(); |
| 4165 | 4161 |
| 4166 if(purple_str_has_prefix(who, "@E ")) { | 4162 if(purple_str_has_prefix(who, "@E ")) { |
| 4167 purple_notify_user_info_add_pair(user_info, _("External User"), NULL); | 4163 purple_notify_user_info_add_pair_html(user_info, _("External User"), NULL); |
| 4168 } | 4164 } |
| 4169 | 4165 |
| 4170 purple_notify_user_info_add_pair(user_info, _("User ID"), who); | 4166 purple_notify_user_info_add_pair_plaintext(user_info, _("User ID"), who); |
| 4171 | 4167 |
| 4172 if(b) { | 4168 if(b) { |
| 4173 guint32 type; | 4169 guint32 type; |
| 4174 | 4170 |
| 4175 if(purple_buddy_get_server_alias(b)) { | 4171 if(purple_buddy_get_server_alias(b)) { |
| 4176 purple_notify_user_info_add_pair(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); | 4172 /* TODO: Check whether it's correct to call add_pair_html, |
| 4173 or if we should be using add_pair_plaintext */ | |
| 4174 purple_notify_user_info_add_pair_html(user_info, _("Full Name"), purple_buddy_get_server_alias(b)); | |
| 4177 } | 4175 } |
| 4178 | 4176 |
| 4179 type = purple_blist_node_get_int((PurpleBlistNode *) b, BUDDY_KEY_CLIENT); | 4177 type = purple_blist_node_get_int((PurpleBlistNode *) b, BUDDY_KEY_CLIENT); |
| 4180 if(type) { | 4178 if(type) { |
| 4181 tmp = g_strdup(mw_client_name(type)); | 4179 tmp2 = mw_client_name(type); |
| 4182 if (!tmp) | 4180 if (tmp2) { |
| 4181 purple_notify_user_info_add_pair_plaintext(user_info, _("Last Known Client"), tmp2); | |
| 4182 } else { | |
| 4183 tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); | 4183 tmp = g_strdup_printf(_("Unknown (0x%04x)<br>"), type); |
| 4184 | 4184 purple_notify_user_info_add_pair_html(user_info, _("Last Known Client"), tmp); |
| 4185 purple_notify_user_info_add_pair(user_info, _("Last Known Client"), tmp); | 4185 g_free(tmp); |
| 4186 | 4186 } |
| 4187 g_free(tmp); | |
| 4188 } | 4187 } |
| 4189 } | 4188 } |
| 4190 | 4189 |
| 4191 tmp = user_supports_text(pd->srvc_aware, who); | 4190 tmp = user_supports_text(pd->srvc_aware, who); |
| 4192 if(tmp) { | 4191 if(tmp) { |
| 4193 purple_notify_user_info_add_pair(user_info, _("Supports"), tmp); | 4192 purple_notify_user_info_add_pair_plaintext(user_info, _("Supports"), tmp); |
| 4194 g_free(tmp); | 4193 g_free(tmp); |
| 4195 } | 4194 } |
| 4196 | 4195 |
| 4197 if(b) { | 4196 if(b) { |
| 4198 purple_notify_user_info_add_pair(user_info, _("Status"), status_text(b)); | 4197 purple_notify_user_info_add_pair_plaintext(user_info, _("Status"), status_text(b)); |
| 4199 | 4198 |
| 4200 /* XXX Is this adding a status message in its own section rather than with the "Status" label? */ | 4199 /* XXX Is this adding a status message in its own section rather than with the "Status" label? */ |
| 4201 tmp2 = mwServiceAware_getText(pd->srvc_aware, &idb); | 4200 tmp2 = mwServiceAware_getText(pd->srvc_aware, &idb); |
| 4202 if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { | 4201 if(tmp2 && g_utf8_validate(tmp2, -1, NULL)) { |
| 4203 tmp = g_markup_escape_text(tmp2, -1); | |
| 4204 purple_notify_user_info_add_section_break(user_info); | 4202 purple_notify_user_info_add_section_break(user_info); |
| 4205 purple_notify_user_info_add_pair(user_info, NULL, tmp); | 4203 purple_notify_user_info_add_pair_plaintext(user_info, NULL, tmp2); |
| 4206 g_free(tmp); | |
| 4207 } | 4204 } |
| 4208 } | 4205 } |
| 4209 | 4206 |
| 4210 /* @todo emit a signal to allow a plugin to override the display of | 4207 /* @todo emit a signal to allow a plugin to override the display of |
| 4211 this notification, so that it can create its own */ | 4208 this notification, so that it can create its own */ |
| 4399 g_return_if_fail(data != NULL); | 4396 g_return_if_fail(data != NULL); |
| 4400 | 4397 |
| 4401 buddy = data->buddy; | 4398 buddy = data->buddy; |
| 4402 | 4399 |
| 4403 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); | 4400 gc = purple_account_get_connection(purple_buddy_get_account(buddy)); |
| 4404 pd = gc->proto_data; | 4401 pd = purple_connection_get_protocol_data(gc); |
| 4405 | 4402 |
| 4406 if(results) | 4403 if(results) |
| 4407 res = results->data; | 4404 res = results->data; |
| 4408 | 4405 |
| 4409 if(!code && res && res->matches) { | 4406 if(!code && res && res->matches) { |
| 4478 } | 4475 } |
| 4479 | 4476 |
| 4480 | 4477 |
| 4481 static void mw_prpl_add_buddy(PurpleConnection *gc, | 4478 static void mw_prpl_add_buddy(PurpleConnection *gc, |
| 4482 PurpleBuddy *buddy, | 4479 PurpleBuddy *buddy, |
| 4483 PurpleGroup *group) { | 4480 PurpleGroup *group, |
| 4484 | 4481 const char *message) { |
| 4485 struct mwPurplePluginData *pd = gc->proto_data; | 4482 |
| 4483 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); | |
| 4486 struct mwServiceResolve *srvc; | 4484 struct mwServiceResolve *srvc; |
| 4487 GList *query; | 4485 GList *query; |
| 4488 enum mwResolveFlag flags; | 4486 enum mwResolveFlag flags; |
| 4489 guint32 req; | 4487 guint32 req; |
| 4490 BuddyAddData *data; | 4488 BuddyAddData *data; |
| 4525 } | 4523 } |
| 4526 | 4524 |
| 4527 | 4525 |
| 4528 static void mw_prpl_add_buddies(PurpleConnection *gc, | 4526 static void mw_prpl_add_buddies(PurpleConnection *gc, |
| 4529 GList *buddies, | 4527 GList *buddies, |
| 4530 GList *groups) { | 4528 GList *groups, |
| 4529 const char *message) { | |
| 4531 | 4530 |
| 4532 struct mwPurplePluginData *pd; | 4531 struct mwPurplePluginData *pd; |
| 4533 GHashTable *group_sets; | 4532 GHashTable *group_sets; |
| 4534 struct mwAwareIdBlock *idbs, *idb; | 4533 struct mwAwareIdBlock *idbs, *idb; |
| 4535 | 4534 |
| 4536 pd = gc->proto_data; | 4535 pd = purple_connection_get_protocol_data(gc); |
| 4537 | 4536 |
| 4538 /* map PurpleGroup:GList of mwAwareIdBlock */ | 4537 /* map PurpleGroup:GList of mwAwareIdBlock */ |
| 4539 group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); | 4538 group_sets = g_hash_table_new(g_direct_hash, g_direct_equal); |
| 4540 | 4539 |
| 4541 /* bunch of mwAwareIdBlock allocated at once, free'd at once */ | 4540 /* bunch of mwAwareIdBlock allocated at once, free'd at once */ |
| 4582 struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; | 4581 struct mwAwareIdBlock idb = { mwAware_USER, (char *)purple_buddy_get_name(buddy), NULL }; |
| 4583 struct mwAwareList *list; | 4582 struct mwAwareList *list; |
| 4584 | 4583 |
| 4585 GList *rem = g_list_prepend(NULL, &idb); | 4584 GList *rem = g_list_prepend(NULL, &idb); |
| 4586 | 4585 |
| 4587 pd = gc->proto_data; | 4586 pd = purple_connection_get_protocol_data(gc); |
| 4588 group = purple_buddy_get_group(buddy); | 4587 group = purple_buddy_get_group(buddy); |
| 4589 list = list_ensure(pd, group); | 4588 list = list_ensure(pd, group); |
| 4590 | 4589 |
| 4591 mwAwareList_removeAware(list, rem); | 4590 mwAwareList_removeAware(list, rem); |
| 4592 blist_schedule(pd); | 4591 blist_schedule(pd); |
| 4629 g_return_if_fail(gc != NULL); | 4628 g_return_if_fail(gc != NULL); |
| 4630 | 4629 |
| 4631 acct = purple_connection_get_account(gc); | 4630 acct = purple_connection_get_account(gc); |
| 4632 g_return_if_fail(acct != NULL); | 4631 g_return_if_fail(acct != NULL); |
| 4633 | 4632 |
| 4634 pd = gc->proto_data; | 4633 pd = purple_connection_get_protocol_data(gc); |
| 4635 g_return_if_fail(pd != NULL); | 4634 g_return_if_fail(pd != NULL); |
| 4636 | 4635 |
| 4637 session = pd->session; | 4636 session = pd->session; |
| 4638 g_return_if_fail(session != NULL); | 4637 g_return_if_fail(session != NULL); |
| 4639 | 4638 |
| 4640 switch(acct->perm_deny) { | 4639 switch(purple_account_get_privacy_type(acct)) { |
| 4641 case PURPLE_PRIVACY_DENY_USERS: | 4640 case PURPLE_PRIVACY_DENY_USERS: |
| 4642 DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); | 4641 DEBUG_INFO("PURPLE_PRIVACY_DENY_USERS\n"); |
| 4643 privacy_fill(&privacy, acct->deny); | 4642 privacy_fill(&privacy, acct->deny); |
| 4644 privacy.deny = TRUE; | 4643 privacy.deny = TRUE; |
| 4645 break; | 4644 break; |
| 4659 DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); | 4658 DEBUG_INFO("PURPLE_PRIVACY_DENY_ALL\n"); |
| 4660 privacy.deny = FALSE; | 4659 privacy.deny = FALSE; |
| 4661 break; | 4660 break; |
| 4662 | 4661 |
| 4663 default: | 4662 default: |
| 4664 DEBUG_INFO("acct->perm_deny is 0x%x\n", acct->perm_deny); | 4663 DEBUG_INFO("acct->perm_deny is 0x%x\n", purple_account_get_privacy_type(acct)); |
| 4665 return; | 4664 return; |
| 4666 } | 4665 } |
| 4667 | 4666 |
| 4668 mwSession_setPrivacyInfo(session, &privacy); | 4667 mwSession_setPrivacyInfo(session, &privacy); |
| 4669 g_free(privacy.users); | 4668 g_free(privacy.users); |
| 4713 GHashTable *components) { | 4712 GHashTable *components) { |
| 4714 | 4713 |
| 4715 struct mwPurplePluginData *pd; | 4714 struct mwPurplePluginData *pd; |
| 4716 char *c, *t; | 4715 char *c, *t; |
| 4717 | 4716 |
| 4718 pd = gc->proto_data; | 4717 pd = purple_connection_get_protocol_data(gc); |
| 4719 | 4718 |
| 4720 c = g_hash_table_lookup(components, CHAT_KEY_NAME); | 4719 c = g_hash_table_lookup(components, CHAT_KEY_NAME); |
| 4721 t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); | 4720 t = g_hash_table_lookup(components, CHAT_KEY_TOPIC); |
| 4722 | 4721 |
| 4723 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { | 4722 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
| 4755 | 4754 |
| 4756 struct mwPurplePluginData *pd; | 4755 struct mwPurplePluginData *pd; |
| 4757 struct mwServiceConference *srvc; | 4756 struct mwServiceConference *srvc; |
| 4758 char *c; | 4757 char *c; |
| 4759 | 4758 |
| 4760 pd = gc->proto_data; | 4759 pd = purple_connection_get_protocol_data(gc); |
| 4761 srvc = pd->srvc_conf; | 4760 srvc = pd->srvc_conf; |
| 4762 | 4761 |
| 4763 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { | 4762 if(g_hash_table_lookup(components, CHAT_KEY_IS_PLACE)) { |
| 4764 ; /* nothing needs doing */ | 4763 ; /* nothing needs doing */ |
| 4765 | 4764 |
| 4787 struct mwPurplePluginData *pd; | 4786 struct mwPurplePluginData *pd; |
| 4788 struct mwConference *conf; | 4787 struct mwConference *conf; |
| 4789 struct mwPlace *place; | 4788 struct mwPlace *place; |
| 4790 struct mwIdBlock idb = { (char *) who, NULL }; | 4789 struct mwIdBlock idb = { (char *) who, NULL }; |
| 4791 | 4790 |
| 4792 pd = gc->proto_data; | 4791 pd = purple_connection_get_protocol_data(gc); |
| 4793 g_return_if_fail(pd != NULL); | 4792 g_return_if_fail(pd != NULL); |
| 4794 | 4793 |
| 4795 conf = ID_TO_CONF(pd, id); | 4794 conf = ID_TO_CONF(pd, id); |
| 4796 | 4795 |
| 4797 if(conf) { | 4796 if(conf) { |
| 4811 int id) { | 4810 int id) { |
| 4812 | 4811 |
| 4813 struct mwPurplePluginData *pd; | 4812 struct mwPurplePluginData *pd; |
| 4814 struct mwConference *conf; | 4813 struct mwConference *conf; |
| 4815 | 4814 |
| 4816 pd = gc->proto_data; | 4815 pd = purple_connection_get_protocol_data(gc); |
| 4817 | 4816 |
| 4818 g_return_if_fail(pd != NULL); | 4817 g_return_if_fail(pd != NULL); |
| 4819 conf = ID_TO_CONF(pd, id); | 4818 conf = ID_TO_CONF(pd, id); |
| 4820 | 4819 |
| 4821 if(conf) { | 4820 if(conf) { |
| 4847 struct mwPurplePluginData *pd; | 4846 struct mwPurplePluginData *pd; |
| 4848 struct mwConference *conf; | 4847 struct mwConference *conf; |
| 4849 char *msg; | 4848 char *msg; |
| 4850 int ret; | 4849 int ret; |
| 4851 | 4850 |
| 4852 pd = gc->proto_data; | 4851 pd = purple_connection_get_protocol_data(gc); |
| 4853 | 4852 |
| 4854 g_return_val_if_fail(pd != NULL, 0); | 4853 g_return_val_if_fail(pd != NULL, 0); |
| 4855 conf = ID_TO_CONF(pd, id); | 4854 conf = ID_TO_CONF(pd, id); |
| 4856 | 4855 |
| 4857 msg = purple_markup_strip_html(message); | 4856 msg = purple_markup_strip_html(message); |
| 4885 | 4884 |
| 4886 static void mw_prpl_alias_buddy(PurpleConnection *gc, | 4885 static void mw_prpl_alias_buddy(PurpleConnection *gc, |
| 4887 const char *who, | 4886 const char *who, |
| 4888 const char *alias) { | 4887 const char *alias) { |
| 4889 | 4888 |
| 4890 struct mwPurplePluginData *pd = gc->proto_data; | 4889 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 4891 g_return_if_fail(pd != NULL); | 4890 g_return_if_fail(pd != NULL); |
| 4892 | 4891 |
| 4893 /* it's a change to the buddy list, so we've gotta reflect that in | 4892 /* it's a change to the buddy list, so we've gotta reflect that in |
| 4894 the server copy */ | 4893 the server copy */ |
| 4895 | 4894 |
| 4903 const char *new_group) { | 4902 const char *new_group) { |
| 4904 | 4903 |
| 4905 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; | 4904 struct mwAwareIdBlock idb = { mwAware_USER, (char *) who, NULL }; |
| 4906 GList *gl = g_list_prepend(NULL, &idb); | 4905 GList *gl = g_list_prepend(NULL, &idb); |
| 4907 | 4906 |
| 4908 struct mwPurplePluginData *pd = gc->proto_data; | 4907 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 4909 PurpleGroup *group; | 4908 PurpleGroup *group; |
| 4910 struct mwAwareList *list; | 4909 struct mwAwareList *list; |
| 4911 | 4910 |
| 4912 /* add who to new_group's aware list */ | 4911 /* add who to new_group's aware list */ |
| 4913 group = purple_find_group(new_group); | 4912 group = purple_find_group(new_group); |
| 4929 static void mw_prpl_rename_group(PurpleConnection *gc, | 4928 static void mw_prpl_rename_group(PurpleConnection *gc, |
| 4930 const char *old, | 4929 const char *old, |
| 4931 PurpleGroup *group, | 4930 PurpleGroup *group, |
| 4932 GList *buddies) { | 4931 GList *buddies) { |
| 4933 | 4932 |
| 4934 struct mwPurplePluginData *pd = gc->proto_data; | 4933 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 4935 g_return_if_fail(pd != NULL); | 4934 g_return_if_fail(pd != NULL); |
| 4936 | 4935 |
| 4937 /* it's a change in the buddy list, so we've gotta reflect that in | 4936 /* it's a change in the buddy list, so we've gotta reflect that in |
| 4938 the server copy. Also, having this function should prevent all | 4937 the server copy. Also, having this function should prevent all |
| 4939 those buddies from being removed and re-added. We don't really | 4938 those buddies from being removed and re-added. We don't really |
| 4949 ; | 4948 ; |
| 4950 } | 4949 } |
| 4951 | 4950 |
| 4952 | 4951 |
| 4953 static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { | 4952 static void mw_prpl_convo_closed(PurpleConnection *gc, const char *who) { |
| 4954 struct mwPurplePluginData *pd = gc->proto_data; | 4953 struct mwPurplePluginData *pd = purple_connection_get_protocol_data(gc); |
| 4955 struct mwServiceIm *srvc; | 4954 struct mwServiceIm *srvc; |
| 4956 struct mwConversation *conv; | 4955 struct mwConversation *conv; |
| 4957 struct mwIdBlock idb = { (char *) who, NULL }; | 4956 struct mwIdBlock idb = { (char *) who, NULL }; |
| 4958 | 4957 |
| 4959 g_return_if_fail(pd != NULL); | 4958 g_return_if_fail(pd != NULL); |
| 4984 | 4983 |
| 4985 static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { | 4984 static void mw_prpl_remove_group(PurpleConnection *gc, PurpleGroup *group) { |
| 4986 struct mwPurplePluginData *pd; | 4985 struct mwPurplePluginData *pd; |
| 4987 struct mwAwareList *list; | 4986 struct mwAwareList *list; |
| 4988 | 4987 |
| 4989 pd = gc->proto_data; | 4988 pd = purple_connection_get_protocol_data(gc); |
| 4990 g_return_if_fail(pd != NULL); | 4989 g_return_if_fail(pd != NULL); |
| 4991 g_return_if_fail(pd->group_list_map != NULL); | 4990 g_return_if_fail(pd->group_list_map != NULL); |
| 4992 | 4991 |
| 4993 list = g_hash_table_lookup(pd->group_list_map, group); | 4992 list = g_hash_table_lookup(pd->group_list_map, group); |
| 4994 | 4993 |
| 5008 struct mwServiceAware *srvc; | 5007 struct mwServiceAware *srvc; |
| 5009 PurpleAccount *acct; | 5008 PurpleAccount *acct; |
| 5010 | 5009 |
| 5011 g_return_val_if_fail(gc != NULL, FALSE); | 5010 g_return_val_if_fail(gc != NULL, FALSE); |
| 5012 | 5011 |
| 5013 pd = gc->proto_data; | 5012 pd = purple_connection_get_protocol_data(gc); |
| 5014 g_return_val_if_fail(pd != NULL, FALSE); | 5013 g_return_val_if_fail(pd != NULL, FALSE); |
| 5015 | 5014 |
| 5016 srvc = pd->srvc_aware; | 5015 srvc = pd->srvc_aware; |
| 5017 g_return_val_if_fail(srvc != NULL, FALSE); | 5016 g_return_val_if_fail(srvc != NULL, FALSE); |
| 5018 | 5017 |
| 5040 | 5039 |
| 5041 DEBUG_INFO("ft_outgoing_init\n"); | 5040 DEBUG_INFO("ft_outgoing_init\n"); |
| 5042 | 5041 |
| 5043 acct = purple_xfer_get_account(xfer); | 5042 acct = purple_xfer_get_account(xfer); |
| 5044 gc = purple_account_get_connection(acct); | 5043 gc = purple_account_get_connection(acct); |
| 5045 pd = gc->proto_data; | 5044 pd = purple_connection_get_protocol_data(gc); |
| 5046 srvc = pd->srvc_ft; | 5045 srvc = pd->srvc_ft; |
| 5047 | 5046 |
| 5048 filename = purple_xfer_get_local_filename(xfer); | 5047 filename = purple_xfer_get_local_filename(xfer); |
| 5049 filesize = purple_xfer_get_size(xfer); | 5048 filesize = purple_xfer_get_size(xfer); |
| 5050 idb.user = xfer->who; | 5049 idb.user = purple_xfer_get_remote_user(xfer); |
| 5051 | 5050 |
| 5052 purple_xfer_update_progress(xfer); | 5051 purple_xfer_update_progress(xfer); |
| 5053 | 5052 |
| 5054 /* test that we can actually send the file */ | 5053 /* test that we can actually send the file */ |
| 5055 fp = g_fopen(filename, "rb"); | 5054 fp = g_fopen(filename, "rb"); |
| 5056 if(! fp) { | 5055 if(! fp) { |
| 5057 char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"), | 5056 char *msg = g_strdup_printf(_("Error reading file %s: \n%s\n"), |
| 5058 filename, g_strerror(errno)); | 5057 filename, g_strerror(errno)); |
| 5059 purple_xfer_error(purple_xfer_get_type(xfer), acct, xfer->who, msg); | 5058 purple_xfer_error(purple_xfer_get_type(xfer), acct, purple_xfer_get_remote_user(xfer), msg); |
| 5060 g_free(msg); | 5059 g_free(msg); |
| 5061 return; | 5060 return; |
| 5062 } | 5061 } |
| 5063 fclose(fp); | 5062 fclose(fp); |
| 5064 | 5063 |
| 5069 | 5068 |
| 5070 ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); | 5069 ft = mwFileTransfer_new(srvc, &idb, NULL, filename, filesize); |
| 5071 | 5070 |
| 5072 purple_xfer_ref(xfer); | 5071 purple_xfer_ref(xfer); |
| 5073 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); | 5072 mwFileTransfer_setClientData(ft, xfer, (GDestroyNotify) purple_xfer_unref); |
| 5074 xfer->data = ft; | 5073 purple_xfer_set_protocol_data(xfer, ft); |
| 5075 | 5074 |
| 5076 mwFileTransfer_offer(ft); | 5075 mwFileTransfer_offer(ft); |
| 5077 } | 5076 } |
| 5078 | 5077 |
| 5079 | 5078 |
| 5080 static void ft_outgoing_cancel(PurpleXfer *xfer) { | 5079 static void ft_outgoing_cancel(PurpleXfer *xfer) { |
| 5081 struct mwFileTransfer *ft = xfer->data; | 5080 struct mwFileTransfer *ft = purple_xfer_get_protocol_data(xfer); |
| 5082 | 5081 |
| 5083 DEBUG_INFO("ft_outgoing_cancel called\n"); | 5082 DEBUG_INFO("ft_outgoing_cancel called\n"); |
| 5084 | 5083 |
| 5085 if(ft) mwFileTransfer_cancel(ft); | 5084 if(ft) mwFileTransfer_cancel(ft); |
| 5086 } | 5085 } |
| 5117 } | 5116 } |
| 5118 } | 5117 } |
| 5119 | 5118 |
| 5120 | 5119 |
| 5121 static PurplePluginProtocolInfo mw_prpl_info = { | 5120 static PurplePluginProtocolInfo mw_prpl_info = { |
| 5121 sizeof(PurplePluginProtocolInfo), | |
| 5122 OPT_PROTO_IM_IMAGE, | 5122 OPT_PROTO_IM_IMAGE, |
| 5123 NULL, /*< set in mw_plugin_init */ | 5123 NULL, /*< set in mw_plugin_init */ |
| 5124 NULL, /*< set in mw_plugin_init */ | 5124 NULL, /*< set in mw_plugin_init */ |
| 5125 NO_BUDDY_ICONS, | 5125 NO_BUDDY_ICONS, |
| 5126 mw_prpl_list_icon, | 5126 mw_prpl_list_icon, |
| 5157 mw_prpl_chat_whisper, | 5157 mw_prpl_chat_whisper, |
| 5158 mw_prpl_chat_send, | 5158 mw_prpl_chat_send, |
| 5159 mw_prpl_keepalive, | 5159 mw_prpl_keepalive, |
| 5160 NULL, | 5160 NULL, |
| 5161 NULL, | 5161 NULL, |
| 5162 NULL, | |
| 5163 mw_prpl_alias_buddy, | 5162 mw_prpl_alias_buddy, |
| 5164 mw_prpl_group_buddy, | 5163 mw_prpl_group_buddy, |
| 5165 mw_prpl_rename_group, | 5164 mw_prpl_rename_group, |
| 5166 mw_prpl_buddy_free, | 5165 mw_prpl_buddy_free, |
| 5167 mw_prpl_convo_closed, | 5166 mw_prpl_convo_closed, |
| 5182 NULL, | 5181 NULL, |
| 5183 NULL, | 5182 NULL, |
| 5184 NULL, | 5183 NULL, |
| 5185 NULL, | 5184 NULL, |
| 5186 NULL, | 5185 NULL, |
| 5187 sizeof(PurplePluginProtocolInfo), | |
| 5188 NULL, | |
| 5189 NULL, | |
| 5190 NULL, | 5186 NULL, |
| 5191 NULL, | 5187 NULL, |
| 5192 NULL, | 5188 NULL, |
| 5193 NULL, | 5189 NULL, |
| 5194 NULL, | 5190 NULL, |
| 5512 struct mwServiceResolve *srvc; | 5508 struct mwServiceResolve *srvc; |
| 5513 GList *query; | 5509 GList *query; |
| 5514 enum mwResolveFlag flags; | 5510 enum mwResolveFlag flags; |
| 5515 guint32 req; | 5511 guint32 req; |
| 5516 | 5512 |
| 5517 pd = gc->proto_data; | 5513 pd = purple_connection_get_protocol_data(gc); |
| 5518 srvc = pd->srvc_resolve; | 5514 srvc = pd->srvc_resolve; |
| 5519 | 5515 |
| 5520 query = g_list_prepend(NULL, (char *) name); | 5516 query = g_list_prepend(NULL, (char *) name); |
| 5521 flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; | 5517 flags = mwResolveFlag_FIRST | mwResolveFlag_GROUPS; |
| 5522 | 5518 |
| 5637 struct mwServiceResolve *srvc; | 5633 struct mwServiceResolve *srvc; |
| 5638 GList *query; | 5634 GList *query; |
| 5639 enum mwResolveFlag flags; | 5635 enum mwResolveFlag flags; |
| 5640 guint32 req; | 5636 guint32 req; |
| 5641 | 5637 |
| 5642 pd = gc->proto_data; | 5638 pd = purple_connection_get_protocol_data(gc); |
| 5643 srvc = pd->srvc_resolve; | 5639 srvc = pd->srvc_resolve; |
| 5644 | 5640 |
| 5645 query = g_list_prepend(NULL, (char *) name); | 5641 query = g_list_prepend(NULL, (char *) name); |
| 5646 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; | 5642 flags = mwResolveFlag_FIRST | mwResolveFlag_USERS; |
| 5647 | 5643 |
