libpurple/protocols/zephyr/zephyr.c

changeset 40701
1f67d7260477
parent 40700
4c3ee00e6107
child 40702
d036174d9e22
equal deleted inserted replaced
40700:4c3ee00e6107 40701:1f67d7260477
103 char *recipient; 103 char *recipient;
104 char *name; 104 char *name;
105 gboolean open; 105 gboolean open;
106 int id; 106 int id;
107 }; 107 };
108
109 #define z_call(func) if (func != ZERR_NONE)\
110 return;
111 #define z_call_r(func) if (func != ZERR_NONE)\
112 return TRUE;
113
114 #define z_call_s(func, err) if (func != ZERR_NONE) {\
115 purple_connection_error(\
116 purple_account_get_connection(zephyr->account),\
117 PURPLE_CONNECTION_ERROR_NETWORK_ERROR, err);\
118 return FALSE;\
119 }
120 108
121 #ifdef WIN32 109 #ifdef WIN32
122 extern const char *username; 110 extern const char *username;
123 #endif 111 #endif
124 112
847 PurpleConnection *gc = (PurpleConnection*) data; 835 PurpleConnection *gc = (PurpleConnection*) data;
848 while (ZPending()) { 836 while (ZPending()) {
849 ZNotice_t notice; 837 ZNotice_t notice;
850 /* XXX add real error reporting */ 838 /* XXX add real error reporting */
851 839
852 z_call_r(ZReceiveNotice(&notice, NULL)); 840 if (ZReceiveNotice(&notice, NULL) != ZERR_NONE) {
841 return TRUE;
842 }
853 843
854 switch (notice.z_kind) { 844 switch (notice.z_kind) {
855 case UNSAFE: 845 case UNSAFE:
856 case UNACKED: 846 case UNACKED:
857 case ACKED: 847 case ACKED:
1400 } 1390 }
1401 1391
1402 static gboolean 1392 static gboolean
1403 login_zeph02(zephyr_account *zephyr) 1393 login_zeph02(zephyr_account *zephyr)
1404 { 1394 {
1405 /* XXX z_call_s should actually try to report the com_err determined error */ 1395 PurpleConnection *pc = purple_account_get_connection(zephyr->account);
1406 z_call_s(ZInitialize(), "Couldn't initialize zephyr"); 1396
1407 z_call_s(ZOpenPort(&(zephyr->port)), "Couldn't open port"); 1397 /* XXX Should actually try to report the com_err determined error */
1408 z_call_s(ZSetLocation(zephyr->exposure), "Couldn't set location"); 1398 if (ZInitialize() != ZERR_NONE) {
1399 purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
1400 "Couldn't initialize zephyr");
1401 return FALSE;
1402 }
1403
1404 if (ZOpenPort(&(zephyr->port)) != ZERR_NONE) {
1405 purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
1406 "Couldn't open port");
1407 return FALSE;
1408 }
1409
1410 if (ZSetLocation(zephyr->exposure) != ZERR_NONE) {
1411 purple_connection_error(pc, PURPLE_CONNECTION_ERROR_NETWORK_ERROR,
1412 "Couldn't set location");
1413 return FALSE;
1414 }
1409 1415
1410 zephyr->username = g_strdup(ZGetSender()); 1416 zephyr->username = g_strdup(ZGetSender());
1411 zephyr->realm = get_zephyr_realm(zephyr->account, ZGetRealm()); 1417 zephyr->realm = get_zephyr_realm(zephyr->account, ZGetRealm());
1412 1418
1413 return TRUE; 1419 return TRUE;
1594 zephyr->nottimer = 0; 1600 zephyr->nottimer = 0;
1595 if (zephyr->loctimer) 1601 if (zephyr->loctimer)
1596 g_source_remove(zephyr->loctimer); 1602 g_source_remove(zephyr->loctimer);
1597 zephyr->loctimer = 0; 1603 zephyr->loctimer = 0;
1598 if (use_zeph02(zephyr)) { 1604 if (use_zeph02(zephyr)) {
1599 z_call(ZCancelSubscriptions(0)); 1605 if (ZCancelSubscriptions(0) != ZERR_NONE) {
1600 z_call(ZUnsetLocation()); 1606 return;
1601 z_call(ZClosePort()); 1607 }
1608 if (ZUnsetLocation() != ZERR_NONE) {
1609 return;
1610 }
1611 if (ZClosePort() != ZERR_NONE) {
1612 return;
1613 }
1602 } else { 1614 } else {
1603 /* assume tzc */ 1615 /* assume tzc */
1604 #ifdef G_OS_UNIX 1616 #ifdef G_OS_UNIX
1605 GError *error = NULL; 1617 GError *error = NULL;
1606 g_subprocess_send_signal(zephyr->tzc_proc, SIGTERM); 1618 g_subprocess_send_signal(zephyr->tzc_proc, SIGTERM);

mercurial