static void roomlist_disco_result_cb(JabberStream *js, xmlnode *packet, gpointer data) { xmlnode *query; xmlnode *item; const char *type; if(!js->roomlist) return; if(!(type = xmlnode_get_attrib(packet, "type")) || strcmp(type, "result")) { char *err = jabber_parse_error(js,packet); gaim_notify_error(js->gc, _("Error"), _("Error retrieving room list"), err); gaim_roomlist_set_in_progress(js->roomlist, FALSE); gaim_roomlist_unref(js->roomlist); js->roomlist = NULL; g_free(err); return; } if(!(query = xmlnode_get_child(packet, "query"))) { char *err = jabber_parse_error(js, packet); gaim_notify_error(js->gc, _("Error"), _("Error retrieving room list"), err); gaim_roomlist_set_in_progress(js->roomlist, FALSE); gaim_roomlist_unref(js->roomlist); js->roomlist = NULL; g_free(err); return; } for(item = xmlnode_get_child(query, "item"); item; item = xmlnode_get_next_twin(item)) { const char *name; GaimRoomlistRoom *room; JabberID *jid; if(!(jid = jabber_id_new(xmlnode_get_attrib(item, "jid")))) continue; name = xmlnode_get_attrib(item, "name"); room = gaim_roomlist_room_new(GAIM_ROOMLIST_ROOMTYPE_ROOM, jid->node, NULL); gaim_roomlist_room_add_field(js->roomlist, room, jid->node); gaim_roomlist_room_add_field(js->roomlist, room, jid->domain); gaim_roomlist_room_add_field(js->roomlist, room, name ? name : ""); gaim_roomlist_room_add(js->roomlist, room); jabber_id_free(jid); } gaim_roomlist_set_in_progress(js->roomlist, FALSE); gaim_roomlist_unref(js->roomlist); js->roomlist = NULL; }
static gint uri_command(const char *command, gboolean sync) { gchar *escaped, *tmp; GError *error = NULL; gint ret = 0; escaped = gaim_escape_html(command); gaim_debug_misc("gtknotify", "Executing %s\n", escaped); if (!gaim_program_is_valid(command)) { tmp = g_strdup_printf(_("The browser command <b>%s</b> is invalid."), escaped ? escaped : "(none)"); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); g_free(tmp); } else if (sync) { gint status; if (!g_spawn_command_line_sync(command, NULL, NULL, &status, &error)) { tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), escaped, error->message); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); g_free(tmp); g_error_free(error); } else ret = status; } else { if (!g_spawn_command_line_async(command, &error)) { tmp = g_strdup_printf(_("Error launching <b>%s</b>: %s"), escaped, error->message); gaim_notify_error(NULL, NULL, _("Unable to open URL"), tmp); g_free(tmp); g_error_free(error); } } g_free(escaped); return ret; }
void jabber_chat_request_room_configure(JabberChat *chat) { JabberIq *iq; char *room_jid; if(!chat) return; chat->config_dialog_handle = NULL; if(!chat->muc) { gaim_notify_error(chat->js->gc, _("Room Configuration Error"), _("Room Configuration Error"), _("This room is not capable of being configured")); return; } iq = jabber_iq_new_query(chat->js, JABBER_IQ_GET, "http://jabber.org/protocol/muc#owner"); room_jid = g_strdup_printf("%s@%s", chat->room, chat->server); xmlnode_set_attrib(iq->node, "to", room_jid); jabber_iq_set_callback(iq, jabber_chat_room_configure_cb, NULL); jabber_iq_send(iq); g_free(room_jid); }
void msn_error_handle(MsnSession *session, unsigned int type) { const char *text; text = msn_error_get_text(type); gaim_notify_error(session->account->gc, NULL, text, NULL); }
static void jabber_chat_room_configure_cb(JabberStream *js, xmlnode *packet, gpointer data) { xmlnode *query, *x; const char *type = xmlnode_get_attrib(packet, "type"); const char *from = xmlnode_get_attrib(packet, "from"); char *msg; JabberChat *chat; JabberID *jid; if(!type || !from) return; if(!strcmp(type, "result")) { jid = jabber_id_new(from); if(!jid) return; chat = jabber_chat_find(js, jid->node, jid->domain); jabber_id_free(jid); if(!chat) return; if(!(query = xmlnode_get_child(packet, "query"))) return; for(x = xmlnode_get_child(query, "x"); x; x = xmlnode_get_next_twin(x)) { const char *xmlns; if(!(xmlns = xmlnode_get_namespace(x))) continue; if(!strcmp(xmlns, "jabber:x:data")) { chat->config_dialog_type = GAIM_REQUEST_FIELDS; chat->config_dialog_handle = jabber_x_data_request(js, x, jabber_chat_room_configure_x_data_cb, chat); return; } } } else if(!strcmp(type, "error")) { char *msg = jabber_parse_error(js, packet); gaim_notify_error(js->gc, _("Configuration error"), _("Configuration error"), msg); if(msg) g_free(msg); return; } msg = g_strdup_printf("Unable to configure room %s", from); gaim_notify_info(js->gc, _("Unable to configure"), _("Unable to configure"), msg); g_free(msg); }
static void gaym_add_permit(GaimConnection * gc, const char *name) { if (!gaym_nick_check(name)) { gaim_privacy_permit_remove(gc->account, name, TRUE); gaim_notify_error(gc, _("Invalid User Name"), name, _("Invalid user name not added.")); } else { gaym_privacy_change(gc, name); } }
void msn_error_handle(MsnSession *session, unsigned int type) { char buf[MSN_BUF_LEN]; g_snprintf(buf, sizeof(buf), _("MSN Error: %s\n"), msn_error_get_text(type)); gaim_notify_error(session->account->gc, NULL, buf, NULL); }
static void gaym_add_deny(GaimConnection * gc, const char *name) { if (!gaym_nick_check(name)) { gaim_privacy_deny_remove(gc->account, name, TRUE); gaim_notify_error(gc, _("Invalid User Name"), name, _("Invalid user name not added.")); return; } gaym_server_store_deny(gc, name, TRUE); gaym_privacy_change(gc, name); }
static void open_button_cb(GtkButton *button, GaimGtkXferDialog *dialog) { #ifdef _WIN32 /* Only supported in Win32 right now */ int code; if (G_WIN32_HAVE_WIDECHAR_API ()) { wchar_t *wc_filename = g_utf8_to_utf16( gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); code = (int) ShellExecuteW(NULL, NULL, wc_filename, NULL, NULL, SW_SHOW); g_free(wc_filename); } else { char *l_filename = g_locale_from_utf8( gaim_xfer_get_local_filename( dialog->selected_xfer), -1, NULL, NULL, NULL); code = (int) ShellExecuteA(NULL, NULL, l_filename, NULL, NULL, SW_SHOW); g_free(l_filename); } if (code == SE_ERR_ASSOCINCOMPLETE || code == SE_ERR_NOASSOC) { gaim_notify_error(NULL, NULL, _("There is no application configured to open this type of file."), NULL); } else if (code < 32) { gaim_notify_error(NULL, NULL, _("An error occurred while opening the file."), NULL); gaim_debug_warning("ft", "filename: %s; code: %d\n", gaim_xfer_get_local_filename(dialog->selected_xfer), code); } #endif }
static void irc_dccsend_network_listen_cb(int sock, gpointer data) { GaimXfer *xfer = data; struct irc_xfer_send_data *xd; GaimConnection *gc; struct irc_conn *irc; const char *arg[2]; char *tmp; struct in_addr addr; unsigned short int port; xd = xfer->data; xd->listen_data = NULL; if (gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_LOCAL || gaim_xfer_get_status(xfer) == GAIM_XFER_STATUS_CANCEL_REMOTE) { gaim_xfer_unref(xfer); return; } xd = xfer->data; gc = gaim_account_get_connection(gaim_xfer_get_account(xfer)); irc = gc->proto_data; gaim_xfer_unref(xfer); if (sock < 0) { gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Gaim could not open a listening port.")); gaim_xfer_cancel_local(xfer); return; } xd->fd = sock; port = gaim_network_get_port_from_fd(sock); gaim_debug_misc("irc", "port is %hu\n", port); /* Monitor the listening socket */ xfer->watcher = gaim_input_add(sock, GAIM_INPUT_READ, irc_dccsend_send_connected, xfer); /* Send the intended recipient the DCC request */ arg[0] = xfer->who; inet_aton(gaim_network_get_my_ip(irc->fd), &addr); arg[1] = tmp = g_strdup_printf("\001DCC SEND \"%s\" %u %hu %" G_GSIZE_FORMAT "\001", xfer->filename, ntohl(addr.s_addr), port, xfer->size); irc_cmd_privmsg(gc->proto_data, "msg", NULL, arg); g_free(tmp); }
static void jabber_si_xfer_send_disco_cb(JabberStream *js, const char *who, JabberCapabilities capabilities, gpointer data) { GaimXfer *xfer = data; if(capabilities & JABBER_CAP_SI_FILE_XFER) { jabber_si_xfer_send_request(xfer); } else { char *msg = g_strdup_printf(_("Unable to send file to %s, user does not support file transfers"), who); gaim_notify_error(js->gc, _("File Send Failed"), _("File Send Failed"), msg); g_free(msg); } }
static void jabber_chat_register_x_data_result_cb(JabberStream *js, xmlnode *packet, gpointer data) { const char *type = xmlnode_get_attrib(packet, "type"); if(type && !strcmp(type, "error")) { char *msg = jabber_parse_error(js, packet); gaim_notify_error(js->gc, _("Registration error"), _("Registration error"), msg); if(msg) g_free(msg); return; } }
void gaim_xfer_error(GaimXferType type, const char *who, const char *msg) { char *title; g_return_if_fail(msg != NULL); g_return_if_fail(type != GAIM_XFER_UNKNOWN); if (type == GAIM_XFER_SEND) title = g_strdup_printf(_("File transfer to %s aborted.\n"), who); else title = g_strdup_printf(_("File transfer from %s aborted.\n"), who); gaim_notify_error(NULL, NULL, title, msg); g_free(title); }
void gaim_connection_register(GaimConnection *gc) { GaimAccount *account; GaimConnectionUiOps *ops; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(gc != NULL); gaim_debug(GAIM_DEBUG_INFO, "connection", "Registering. gc = %p\n", gc); ops = gaim_get_connection_ui_ops(); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); else { gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(gaim_connection_get_account(gc))); gaim_debug(GAIM_DEBUG_ERROR, "connection", "Could not get prpl info for %p\n", gc); gaim_notify_error(NULL, _("Registration Error"), message, NULL); g_free(message); return; } account = gaim_connection_get_account(gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) return; gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling register_user\n"); prpl_info->register_user(account); }
static void save_writefile_cb(void *user_data, const char *filename) { DebugWindow *win = (DebugWindow *)user_data; FILE *fp; char *tmp; if ((fp = g_fopen(filename, "w+")) == NULL) { gaim_notify_error(win, NULL, _("Unable to open file."), NULL); return; } tmp = gtk_imhtml_get_text(GTK_IMHTML(win->text), NULL, NULL); fprintf(fp, "Gaim Debug log : %s\n", gaim_date_full()); fprintf(fp, "%s", tmp); g_free(tmp); fclose(fp); }
/* * This function is called after the user has selected a file to send. */ static void irc_dccsend_send_init(GaimXfer *xfer) { GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer)); struct irc_xfer_send_data *xd = xfer->data; xfer->filename = g_path_get_basename(xfer->local_filename); gaim_xfer_ref(xfer); /* Create a listening socket */ xd->listen_data = gaim_network_listen_range(0, 0, SOCK_STREAM, irc_dccsend_network_listen_cb, xfer); if (xd->listen_data == NULL) { gaim_xfer_unref(xfer); gaim_notify_error(gc, NULL, _("File Transfer Failed"), _("Gaim could not open a listening port.")); gaim_xfer_cancel_local(xfer); } }
static void irc_view_motd(GaimPluginAction *action) { GaimConnection *gc = (GaimConnection *) action->context; struct irc_conn *irc; char *title; if (gc == NULL || gc->proto_data == NULL) { gaim_debug(GAIM_DEBUG_ERROR, "irc", "got MOTD request for NULL gc\n"); return; } irc = gc->proto_data; if (irc->motd == NULL) { gaim_notify_error(gc, _("Error displaying MOTD"), _("No MOTD available"), _("There is no MOTD associated with this connection.")); return; } title = g_strdup_printf(_("MOTD for %s"), irc->server); gaim_notify_formatted(gc, title, title, NULL, irc->motd->str, NULL, NULL); g_free(title); }
static void dologin(GtkWidget *widget, GtkWidget *w) { GaimAccount *account; GtkWidget *item; const char *password = gtk_entry_get_text(GTK_ENTRY(pass)); item = gtk_menu_get_active(GTK_MENU(gtk_option_menu_get_menu(GTK_OPTION_MENU(name)))); account = g_object_get_data(G_OBJECT(item), "account"); if (!account) { gaim_notify_error(NULL, NULL, _("Please create an account."), NULL); return; } gaim_account_set_password(account, (*password != '\0') ? password : NULL); #ifdef GAIM_SMALL_SCREEN account->ui_data = vbox_toplevel; #endif gaim_account_connect(account); }
/* * This function is called after the user has selected a file to send. */ static void gaym_dccsend_send_init(GaimXfer *xfer) { struct gaym_xfer_send_data *xd = xfer->data; GaimConnection *gc = gaim_account_get_connection(gaim_xfer_get_account(xfer)); struct gaym_conn *gaym = gc->proto_data; int sock; const char *arg[2]; char *tmp; struct in_addr addr; unsigned short int port; xfer->filename = g_path_get_basename(xfer->local_filename); /* Create a listening socket */ sock = gaim_network_listen_range(0, 0); if (sock < 0) { gaim_notify_error(gc, NULL, _("File Transfer Aborted"), _("Gaim could not open a listening port.")); gaim_xfer_cancel_local(xfer); return; } xd->fd = sock; port = gaim_network_get_port_from_fd(sock); gaim_debug_misc("gaym", "port is %hu\n", port); /* Monitor the listening socket */ xfer->watcher = gaim_input_add(sock, GAIM_INPUT_READ, gaym_dccsend_send_connected, xfer); /* Send the intended recipient the DCC request */ arg[0] = xfer->who; inet_aton(gaim_network_get_my_ip(gaym->fd), &addr); arg[1] = tmp = g_strdup_printf("\001DCC SEND \"%s\" %u %hu %zu\001", xfer->filename, ntohl(addr.s_addr), port, xfer->size); gaym_cmd_privmsg(xfer->account->gc->proto_data, "msg", NULL, arg); g_free(tmp); }
static void group_error_helper(MsnSession *session, const char *msg, int group_id, int error) { GaimAccount *account; GaimConnection *gc; char *reason = NULL; char *title = NULL; account = session->account; gc = gaim_account_get_connection(account); if (error == 224) { if (group_id == 0) { return; } else { const char *group_name; group_name = msn_userlist_find_group_name(session->userlist, group_id); reason = g_strdup_printf(_("%s is not a valid group."), group_name); } } else { reason = g_strdup(_("Unknown error.")); } title = g_strdup_printf(_("%s on %s (%s)"), msg, gaim_account_get_username(account), gaim_account_get_protocol_name(account)); gaim_notify_error(gc, NULL, title, reason); g_free(title); g_free(reason); }
static void roomlist_ok_cb(JabberStream *js, const char *server) { JabberIq *iq; if(!js->roomlist) return; if(!server || !*server) { gaim_notify_error(js->gc, _("Invalid Server"), _("Invalid Server"), NULL); return; } gaim_roomlist_set_in_progress(js->roomlist, TRUE); iq = jabber_iq_new_query(js, JABBER_IQ_GET, "http://jabber.org/protocol/disco#items"); xmlnode_set_attrib(iq->node, "to", server); jabber_iq_set_callback(iq, roomlist_disco_result_cb, NULL); jabber_iq_send(iq); }
void gaim_connection_connect(GaimConnection *gc) { GaimAccount *account; GaimConnectionUiOps *ops; GaimPluginProtocolInfo *prpl_info = NULL; g_return_if_fail(gc != NULL); gaim_debug(GAIM_DEBUG_INFO, "connection", "Connecting. gc = %p\n", gc); ops = gaim_get_connection_ui_ops(); if (gc->prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); else { gchar *message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(gaim_connection_get_account(gc))); gaim_debug(GAIM_DEBUG_ERROR, "connection", "Could not get prpl info for %p\n", gc); gaim_notify_error(NULL, _("Connection Error"), message, NULL); g_free(message); return; } account = gaim_connection_get_account(gc); if (gaim_connection_get_state(gc) != GAIM_DISCONNECTED) return; if (!(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL) && gaim_account_get_password(account) == NULL) { gchar *primary; gchar *escaped; const gchar *username = gaim_account_get_username(account); gaim_debug(GAIM_DEBUG_INFO, "connection", "Requesting password\n"); gaim_connection_destroy(gc); escaped = g_markup_escape_text(username, strlen(username)); primary = g_strdup_printf(_("Enter password for %s"), escaped); gaim_request_input(gc, NULL, primary, NULL, NULL, FALSE, TRUE, _("OK"), G_CALLBACK(request_pass_ok_cb), _("Cancel"), NULL, account); g_free(primary); g_free(escaped); return; } gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); gaim_debug(GAIM_DEBUG_INFO, "connection", "Calling serv_login\n"); serv_login(account); }
void yahoo_process_chat_goto(GaimConnection *gc, struct yahoo_packet *pkt) { if (pkt->status == -1) gaim_notify_error(gc, NULL, _("Failed to join buddy in chat"), _("Maybe they're not in a chat?")); }
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) { GaimAccount *account = gaim_connection_get_account(gc); struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; GaimConversation *c = NULL; GSList *l; GList *members = NULL; GList *roomies = NULL; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; if (pkt->status == -1) { /* We can't join */ struct yahoo_pair *pair = pkt->hash->data; gchar const *failed_to_join = _("Failed to join chat"); switch (atoi(pair->value)) { case 0xFFFFFFFA: /* -6 */ gaim_notify_error(gc, NULL, failed_to_join, _("Unknown room")); break; case 0xFFFFFFF1: /* -15 */ gaim_notify_error(gc, NULL, failed_to_join, _("Maybe the room is full")); break; case 0xFFFFFFDD: /* -35 */ gaim_notify_error(gc, NULL, failed_to_join, _("Not available")); break; default: gaim_notify_error(gc, NULL, failed_to_join, _("Unknown error. You may need to logout and wait five minutes before being able to rejoin a chatroom")); } return; } for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: room = yahoo_string_decode(gc, pair->value, TRUE); break; case 105: topic = yahoo_string_decode(gc, pair->value, TRUE); break; case 128: someid = pair->value; break; case 108: /* number of joiners */ break; case 129: someotherid = pair->value; break; case 130: somebase64orhashosomething = pair->value; break; case 126: somenegativenumber = pair->value; break; case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */ break; case 61: /*this looks similar to 130 */ break; /* the previous section was just room info. this next section is info about individual room members, (including us) */ case 109: /* the yahoo id */ members = g_list_append(members, pair->value); break; case 110: /* age */ break; case 141: /* nickname */ break; case 142: /* location */ break; case 113: /* bitmask */ break; } } if (room && yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) yahoo_chat_leave(gc, room, gaim_connection_get_display_name(gc), FALSE); c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (room && (!c || gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) && members && ((g_list_length(members) > 1) || !g_ascii_strcasecmp(members->data, gaim_connection_get_display_name(gc)))) { int i; GList *flags = NULL; for (i = 0; i < g_list_length(members); i++) flags = g_list_append(flags, GINT_TO_POINTER(GAIM_CBFLAGS_NONE)); if (c && gaim_conv_chat_has_left(GAIM_CONV_CHAT(c))) { /* this might be a hack, but oh well, it should nicely */ char *tmpmsg; gaim_conversation_set_name(c, room); c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); tmpmsg = g_strdup_printf(_("You are now chatting in %s."), room); gaim_conv_chat_write(GAIM_CONV_CHAT(c), "", tmpmsg, GAIM_MESSAGE_SYSTEM, time(NULL)); g_free(tmpmsg); } else { c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_conv_chat_set_topic(GAIM_CONV_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_conv_chat_add_users(GAIM_CONV_CHAT(c), members, NULL, flags, FALSE); } g_list_free(flags); } else if (c) { yahoo_chat_add_users(GAIM_CONV_CHAT(c), members); } if (account->deny && c) { GaimConversationUiOps *ops = gaim_conversation_get_ui_ops(c); for (l = account->deny; l != NULL; l = l->next) { for (roomies = members; roomies; roomies = roomies->next) { if (!gaim_utf8_strcasecmp((char *)l->data, roomies->data)) { gaim_debug_info("yahoo", "Ignoring room member %s in room %s\n" , roomies->data, room ? room : ""); gaim_conv_chat_ignore(GAIM_CONV_CHAT(c),roomies->data); ops->chat_update_user(c, roomies->data); } } } } g_list_free(roomies); g_list_free(members); g_free(room); g_free(topic); }
void yahoo_process_chat_join(GaimConnection *gc, struct yahoo_packet *pkt) { struct yahoo_data *yd = (struct yahoo_data *) gc->proto_data; GaimConversation *c = NULL; GSList *l; GList *members = NULL; char *room = NULL; char *topic = NULL; char *someid, *someotherid, *somebase64orhashosomething, *somenegativenumber; if (pkt->status == -1) { gaim_notify_error(gc, NULL, _("Failed to join chat"), _("Maybe the room is full?")); return; } for (l = pkt->hash; l; l = l->next) { struct yahoo_pair *pair = l->data; switch (pair->key) { case 104: room = pair->value; break; case 105: topic = pair->value; break; case 128: someid = pair->value; break; case 108: /* number of joiners */ break; case 129: someotherid = pair->value; break; case 130: somebase64orhashosomething = pair->value; break; case 126: somenegativenumber = pair->value; break; case 13: /* this is 1. maybe its the type of room? (normal, user created, private, etc?) */ break; case 61: /*this looks similiar to 130 */ break; /* the previous section was just room info. this next section is info about individual room members, (including us) */ case 109: /* the yahoo id */ members = g_list_append(members, pair->value); break; case 110: /* age */ break; case 141: /* nickname */ break; case 142: /* location */ break; case 113: /* bitmask */ break; } } if (!room) return; if (yd->chat_name && gaim_utf8_strcasecmp(room, yd->chat_name)) yahoo_c_leave(gc, YAHOO_CHAT_ID); c = gaim_find_chat(gc, YAHOO_CHAT_ID); if (!c) { c = serv_got_joined_chat(gc, YAHOO_CHAT_ID, room); if (topic) gaim_chat_set_topic(GAIM_CHAT(c), NULL, topic); yd->in_chat = 1; yd->chat_name = g_strdup(room); gaim_chat_add_users(GAIM_CHAT(c), members); } else { yahoo_chat_add_users(GAIM_CHAT(c), members); } g_list_free(members); }
int main(int argc, char *argv[]) #endif { int opt_acct = 0, opt_help = 0, opt_version = 0, opt_login = 0, opt_nologin = 0, dologin_ret = -1; char *opt_user_arg = NULL, *opt_login_arg = NULL; char *opt_session_arg = NULL, *opt_config_dir_arg = NULL; #ifdef ENABLE_HILDON char *plugin_search_paths[4]; #else char *plugin_search_paths[3]; #endif #if HAVE_SIGNAL_H int sig_indx; /* for setting up signal catching */ sigset_t sigset; void (*prev_sig_disp)(); #endif int opt, opt_user = 0; int i; gboolean gui_check; gchar *gaimrc, *accountsxml; struct option long_options[] = { {"acct", no_argument, NULL, 'a'}, /*{"away", optional_argument, NULL, 'w'}, */ {"help", no_argument, NULL, 'h'}, /*{"login", optional_argument, NULL, 'l'}, */ {"loginwin", no_argument, NULL, 'n'}, {"user", required_argument, NULL, 'u'}, {"config", required_argument, NULL, 'c'}, {"debug", no_argument, NULL, 'd'}, {"version", no_argument, NULL, 'v'}, {"session", required_argument, NULL, 's'}, {0, 0, 0, 0} }; #ifdef DEBUG opt_debug = 1; #endif #ifndef _WIN32 br_set_locate_fallback_func(gaim_find_binary_location, argv[0]); #endif #ifdef ENABLE_NLS bindtextdomain(PACKAGE, LOCALEDIR); bind_textdomain_codeset(PACKAGE, "UTF-8"); textdomain(PACKAGE); #endif #if HAVE_SIGNAL_H /* Let's not violate any PLA's!!!! */ /* jseymour: whatever the fsck that means */ /* Robot101: for some reason things like gdm like to block * * useful signals like SIGCHLD, so we unblock all the ones we * * declare a handler for. thanks JSeymour and Vann. */ if (sigemptyset(&sigset)) { char errmsg[BUFSIZ]; snprintf(errmsg, BUFSIZ, "Warning: couldn't initialise empty signal set"); perror(errmsg); } for(sig_indx = 0; catch_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(catch_sig_list[sig_indx], sighandler)) == SIG_ERR) { char errmsg[BUFSIZ]; snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d for catching", catch_sig_list[sig_indx]); perror(errmsg); } if(sigaddset(&sigset, catch_sig_list[sig_indx])) { char errmsg[BUFSIZ]; snprintf(errmsg, BUFSIZ, "Warning: couldn't include signal %d for unblocking", catch_sig_list[sig_indx]); perror(errmsg); } } for(sig_indx = 0; ignore_sig_list[sig_indx] != -1; ++sig_indx) { if((prev_sig_disp = signal(ignore_sig_list[sig_indx], SIG_IGN)) == SIG_ERR) { char errmsg[BUFSIZ]; snprintf(errmsg, BUFSIZ, "Warning: couldn't set signal %d to ignore", ignore_sig_list[sig_indx]); perror(errmsg); } } if (sigprocmask(SIG_UNBLOCK, &sigset, NULL)) { char errmsg[BUFSIZ]; snprintf(errmsg, BUFSIZ, "Warning: couldn't unblock signals"); perror(errmsg); } #endif for (i = 0; i < argc; i++) { /* --login option */ if (strstr(argv[i], "--l") == argv[i]) { char *equals; opt_login = 1; if ((equals = strchr(argv[i], '=')) != NULL) { /* --login=NAME */ opt_login_arg = g_strdup(equals + 1); if (strlen(opt_login_arg) == 0) { g_free(opt_login_arg); opt_login_arg = NULL; } } else if (i + 1 < argc && argv[i + 1][0] != '-') { /* --login NAME */ opt_login_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); } strcpy(argv[i], " "); } /* -l option */ else if (strstr(argv[i], "-l") == argv[i]) { opt_login = 1; if (strlen(argv[i]) > 2) { /* -lNAME */ opt_login_arg = g_strdup(argv[i] + 2); } else if (i + 1 < argc && argv[i + 1][0] != '-') { /* -l NAME */ opt_login_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); } strcpy(argv[i], " "); } /* --away option */ else if (strstr(argv[i], "--aw") == argv[i]) { char *equals; opt_away = 1; if ((equals = strchr(argv[i], '=')) != NULL) { /* --away=MESG */ opt_away_arg = g_strdup(equals + 1); if (strlen(opt_away_arg) == 0) { g_free(opt_away_arg); opt_away_arg = NULL; } } else if (i + 1 < argc && argv[i + 1][0] != '-') { /* --away MESG */ opt_away_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); } strcpy(argv[i], " "); } /* -w option */ else if (strstr(argv[i], "-w") == argv[i]) { opt_away = 1; if (strlen(argv[i]) > 2) { /* -wMESG */ opt_away_arg = g_strdup(argv[i] + 2); } else if (i + 1 < argc && argv[i + 1][0] != '-') { /* -w MESG */ opt_away_arg = g_strdup(argv[i + 1]); strcpy(argv[i + 1], " "); } strcpy(argv[i], " "); } } /* if (opt_login) { printf ("--login given with arg %s\n", opt_login_arg ? opt_login_arg : "NULL"); exit(0); } */ gui_check = gtk_init_check(&argc, &argv); /* scan command-line options */ opterr = 1; while ((opt = getopt_long(argc, argv, #ifndef _WIN32 "adhu:c:vns:", #else "adhu:c:vn", #endif long_options, NULL)) != -1) { switch (opt) { case 'u': /* set user */ opt_user = 1; opt_user_arg = g_strdup(optarg); break; case 'a': /* account editor */ opt_acct = 1; break; case 'd': /* debug */ opt_debug = 1; break; case 'c': /* use specified config dir */ set_gaim_user_dir(optarg); opt_config_dir_arg = g_strdup(optarg); break; case 's': /* use existing session ID */ opt_session_arg = g_strdup(optarg); break; case 'v': /* version */ opt_version = 1; break; case 'h': /* help */ opt_help = 1; break; case 'n': /* don't autologin */ opt_nologin = 1; break; case '?': default: show_usage(1, argv[0]); return 0; break; } } /* show help message */ if (opt_help) { show_usage(0, argv[0]); return 0; } /* show version message */ if (opt_version) { printf("Gaim %s\n",VERSION); return 0; } if (!gui_check) { char *display = gdk_get_display(); g_warning("cannot open display: %s", display ? display : "unset"); g_free(display); return 1; } #ifdef _WIN32 wgaim_init(hint); #endif gaim_core_set_ui_ops(gaim_gtk_core_get_ui_ops()); gaim_eventloop_set_ui_ops(gaim_gtk_eventloop_get_ui_ops()); #ifdef ENABLE_HILDON app = hildon_app_new(); hildon_app_set_two_part_title(HILDON_APP(app), TRUE); hildon_app_set_title(HILDON_APP(app), _("Gaim")); hildon_app_set_autoregistration(HILDON_APP(app), TRUE); /* I will catch the key events here to change views */ g_signal_connect(G_OBJECT(app), "key_press_event", G_CALLBACK(app_key_press_cb), app); g_signal_connect(G_OBJECT(app), "key_press_event", G_CALLBACK(app_key_press_cb), app); g_signal_connect(G_OBJECT(app), "delete_event", G_CALLBACK(app_delete_event_proxy), app); gtk_widget_show_all( GTK_WIDGET( app ) ); /* register with osso initialize */ context = osso_initialize("org.maemo." PACKAGE, PACKAGE_VERSION, FALSE, NULL); osso_application_set_top_cb(context, osso_top_callback, (gpointer)app); #endif if (!gaim_core_init(GAIM_GTK_UI)) { fprintf(stderr, "Initialization of the Gaim core failed. Dumping core.\n" "Please report this!\n"); abort(); } plugin_search_paths[0] = g_strdup(LIBDIR); plugin_search_paths[1] = gaim_user_dir(); plugin_search_paths[2] = g_build_filename(gaim_user_dir(), "plugins", NULL); #ifdef ENABLE_HILDON plugin_search_paths[3] = g_strdup("/var/lib/install/etc/gaim/plugins"); #endif gaim_plugins_set_search_paths(sizeof(plugin_search_paths) / sizeof(*plugin_search_paths), plugin_search_paths); g_free(plugin_search_paths[0]); g_free(plugin_search_paths[2]); gaim_plugins_probe(NULL); /* XXX - Remove this check. Maybe in 2005. --KingAnt, 25 Jul 2004 */ gaimrc = g_build_filename(gaim_home_dir(), ".gaimrc", NULL); accountsxml = g_build_filename(gaim_user_dir(), "accounts.xml", NULL); if (g_file_test(gaimrc, G_FILE_TEST_EXISTS) && !g_file_test(accountsxml, G_FILE_TEST_EXISTS)) { gaim_notify_error(NULL, NULL, _("Unable to load preferences"), _("Gaim was not able to load your preferences because they are stored in an old format that is no longer used. Please reconfigure your settings using the Preferences window.")); } g_free(gaimrc); g_free(accountsxml); gaim_accounts_load(); gaim_set_blist(gaim_blist_new()); gaim_blist_load(); gaim_prefs_load(); gaim_prefs_update_old(); gaim_gtk_prefs_update_old(); /* load plugins we had when we quit */ gaim_plugins_load_saved("/gaim/gtk/plugins/loaded"); gaim_pounces_load(); gaim_status_load(); ui_main(); #ifdef USE_SM session_init(argv[0], opt_session_arg, opt_config_dir_arg); #endif if (opt_session_arg != NULL) { g_free(opt_session_arg); opt_session_arg = NULL; } if (opt_config_dir_arg != NULL) { g_free(opt_config_dir_arg); opt_config_dir_arg = NULL; } /* set the default username */ if (opt_user_arg != NULL) { set_first_user(opt_user_arg); g_free(opt_user_arg); opt_user_arg = NULL; } #ifndef GAIM_SMALL_SCREEN if (gaim_prefs_get_bool("/gaim/gtk/debug/enabled")) gaim_gtk_debug_window_show(); #endif /* deal with --login */ if (opt_login) { dologin_ret = dologin_named(opt_login_arg); if (opt_login_arg != NULL) { g_free(opt_login_arg); opt_login_arg = NULL; } } if (!opt_acct && !opt_nologin) gaim_accounts_auto_login(GAIM_GTK_UI); if (opt_acct) { gaim_gtk_accounts_window_show(); } else if ((dologin_ret == -1) && !gaim_connections_get_all()) show_login(); #ifdef HAVE_STARTUP_NOTIFICATION startup_notification_complete(); #endif gtk_main(); gaim_sound_shutdown(); #ifdef _WIN32 wgaim_cleanup(); #endif #ifdef ENABLE_HILDON gtk_widget_destroy(app); #endif return 0; }
void gaim_connection_new(GaimAccount *account, gboolean regist, const char *password) { GaimConnection *gc; GaimPlugin *prpl; GaimPluginProtocolInfo *prpl_info; g_return_if_fail(account != NULL); if (!gaim_account_is_disconnected(account)) return; prpl = gaim_find_prpl(gaim_account_get_protocol_id(account)); if (prpl != NULL) prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(prpl); else { gchar *message; message = g_strdup_printf(_("Missing protocol plugin for %s"), gaim_account_get_username(account)); gaim_notify_error(NULL, regist ? _("Registration Error") : _("Connection Error"), message, NULL); g_free(message); return; } if (regist) { if (prpl_info->register_user == NULL) return; } else { if (((password == NULL) || (*password == '\0')) && !(prpl_info->options & OPT_PROTO_NO_PASSWORD) && !(prpl_info->options & OPT_PROTO_PASSWORD_OPTIONAL)) { gaim_debug_error("connection", "Can not connect to account %s without " "a password.\n", gaim_account_get_username(account)); return; } } gc = g_new0(GaimConnection, 1); GAIM_DBUS_REGISTER_POINTER(gc, GaimConnection); gc->prpl = prpl; if ((password != NULL) && (*password != '\0')) gc->password = g_strdup(password); gaim_connection_set_account(gc, account); gaim_connection_set_state(gc, GAIM_CONNECTING); connections = g_list_append(connections, gc); gaim_account_set_connection(account, gc); gaim_signal_emit(gaim_connections_get_handle(), "signing-on", gc); if (regist) { gaim_debug_info("connection", "Registering. gc = %p\n", gc); /* set this so we don't auto-reconnect after registering */ gc->wants_to_die = TRUE; prpl_info->register_user(account); } else { gaim_debug_info("connection", "Connecting. gc = %p\n", gc); gaim_signal_emit(gaim_accounts_get_handle(), "account-connecting", account); prpl_info->login(account); } }
static void add_error(MsnCmdProc *cmdproc, MsnTransaction *trans, int error) { MsnSession *session; GaimAccount *account; GaimConnection *gc; const char *list, *passport; char *reason = NULL; char *msg = NULL; char **params; session = cmdproc->session; account = session->account; gc = gaim_account_get_connection(account); params = g_strsplit(trans->params, " ", 0); list = params[0]; passport = params[1]; if (!strcmp(list, "FL")) msg = g_strdup_printf(_("Unable to add user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); else if (!strcmp(list, "BL")) msg = g_strdup_printf(_("Unable to block user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); else if (!strcmp(list, "AL")) msg = g_strdup_printf(_("Unable to permit user on %s (%s)"), gaim_account_get_username(account), gaim_account_get_protocol_name(account)); if (!strcmp(list, "FL")) { if (error == 210) { reason = g_strdup_printf(_("%s could not be added because " "your buddy list is full."), passport); } } if (reason == NULL) { if (error == 208) { reason = g_strdup_printf(_("%s is not a valid passport account."), passport); } else if (error == 500) { reason = g_strdup(_("Service Temporarily Unavailable.")); } else { reason = g_strdup(_("Unknown error.")); } } if (msg != NULL) { gaim_notify_error(gc, NULL, msg, reason); g_free(msg); } if (!strcmp(list, "FL")) { GaimBuddy *buddy; buddy = gaim_find_buddy(account, passport); if (buddy != NULL) gaim_blist_remove_buddy(buddy); } g_free(reason); g_strfreev(params); }
static void * gaim_gtk_notify_uri(const char *uri) { #ifndef _WIN32 char *command = NULL; char *remote_command = NULL; const char *web_browser; int place; web_browser = gaim_prefs_get_string("/gaim/gtk/browsers/browser"); place = gaim_prefs_get_int("/gaim/gtk/browsers/place"); /* if they are running gnome, use the gnome web browser */ if (gaim_running_gnome() == TRUE) { command = g_strdup_printf("gnome-open \"%s\"", uri); } else if (!strcmp(web_browser, "epiphany") || !strcmp(web_browser, "galeon")) { if (place == GAIM_BROWSER_NEW_WINDOW) command = g_strdup_printf("%s -w \"%s\"", web_browser, uri); else if (place == GAIM_BROWSER_NEW_TAB) command = g_strdup_printf("%s -n \"%s\"", web_browser, uri); else command = g_strdup_printf("%s \"%s\"", web_browser, uri); } else if (!strcmp(web_browser, "gnome-open")) { command = g_strdup_printf("gnome-open \"%s\"", uri); } else if (!strcmp(web_browser, "kfmclient")) { command = g_strdup_printf("kfmclient openURL \"%s\"", uri); /* * Does Konqueror have options to open in new tab * and/or current window? */ } else if (!strcmp(web_browser, "mozilla") || !strcmp(web_browser, "mozilla-firebird") || !strcmp(web_browser, "firefox")) { char *args = ""; command = g_strdup_printf("%s \"%s\"", web_browser, uri); /* * Firefox 0.9 and higher require a "-a firefox" option when * using -remote commands. This breaks older versions of * mozilla. So we include this other handly little string * when calling firefox. If the API for remote calls changes * any more in firefox then firefox should probably be split * apart from mozilla-firebird and mozilla... but this is good * for now. */ if (!strcmp(web_browser, "firefox")) args = "-a firefox"; if (place == GAIM_BROWSER_NEW_WINDOW) remote_command = g_strdup_printf("%s %s -remote " "\"openURL(%s,new-window)\"", web_browser, args, uri); else if (place == GAIM_BROWSER_NEW_TAB) remote_command = g_strdup_printf("%s %s -remote " "\"openURL(%s,new-tab)\"", web_browser, args, uri); else if (place == GAIM_BROWSER_CURRENT) remote_command = g_strdup_printf("%s %s -remote " "\"openURL(%s)\"", web_browser, args, uri); } else if (!strcmp(web_browser, "netscape")) { command = g_strdup_printf("netscape \"%s\"", uri); if (place == GAIM_BROWSER_NEW_WINDOW) { remote_command = g_strdup_printf("netscape -remote " "\"openURL(%s,new-window)\"", uri); } else if (place == GAIM_BROWSER_CURRENT) { remote_command = g_strdup_printf("netscape -remote " "\"openURL(%s)\"", uri); } } else if (!strcmp(web_browser, "opera")) { if (place == GAIM_BROWSER_NEW_WINDOW) command = g_strdup_printf("opera -newwindow \"%s\"", uri); else if (place == GAIM_BROWSER_NEW_TAB) command = g_strdup_printf("opera -newpage \"%s\"", uri); else if (place == GAIM_BROWSER_CURRENT) { remote_command = g_strdup_printf("opera -remote " "\"openURL(%s)\"", uri); command = g_strdup_printf("opera \"%s\"", uri); } else command = g_strdup_printf("opera \"%s\"", uri); } else if (!strcmp(web_browser, "custom")) { const char *web_command; web_command = gaim_prefs_get_string("/gaim/gtk/browsers/command"); if (web_command == NULL || *web_command == '\0') { gaim_notify_error(NULL, NULL, _("Unable to open URL"), _("The 'Manual' browser command has been " "chosen, but no command has been set.")); return NULL; } if (strstr(web_command, "%s")) command = gaim_strreplace(web_command, "%s", uri); else { /* * There is no "%s" in the browser command. Assume the user * wanted the URL tacked on to the end of the command. */ command = g_strdup_printf("%s %s", web_command, uri); } } if (remote_command != NULL) { /* try the remote command first */ if (uri_command(remote_command, TRUE) != 0) uri_command(command, FALSE); g_free(remote_command); } else uri_command(command, FALSE); g_free(command); #else /* !_WIN32 */ wgaim_notify_uri(uri); #endif /* !_WIN32 */ return NULL; }
void jabber_chat_join(GaimConnection *gc, GHashTable *data) { JabberChat *chat; char *room, *server, *handle, *passwd; xmlnode *presence, *x; char *tmp, *room_jid, *full_jid; JabberStream *js = gc->proto_data; GaimPresence *gpresence; GaimStatus *status; JabberBuddyState state; char *msg; int priority; room = g_hash_table_lookup(data, "room"); server = g_hash_table_lookup(data, "server"); handle = g_hash_table_lookup(data, "handle"); passwd = g_hash_table_lookup(data, "password"); if(!room || !server) return; if(!handle) handle = js->user->node; if(!jabber_nodeprep_validate(room)) { char *buf = g_strdup_printf(_("%s is not a valid room name"), room); gaim_notify_error(gc, _("Invalid Room Name"), _("Invalid Room Name"), buf); g_free(buf); return; } else if(!jabber_nameprep_validate(server)) { char *buf = g_strdup_printf(_("%s is not a valid server name"), server); gaim_notify_error(gc, _("Invalid Server Name"), _("Invalid Server Name"), buf); g_free(buf); return; } else if(!jabber_resourceprep_validate(handle)) { char *buf = g_strdup_printf(_("%s is not a valid room handle"), handle); gaim_notify_error(gc, _("Invalid Room Handle"), _("Invalid Room Handle"), buf); } if(jabber_chat_find(js, room, server)) return; tmp = g_strdup_printf("%s@%s", room, server); room_jid = g_strdup(jabber_normalize(NULL, tmp)); g_free(tmp); chat = g_new0(JabberChat, 1); chat->js = gc->proto_data; chat->room = g_strdup(room); chat->server = g_strdup(server); chat->handle = g_strdup(handle); chat->members = g_hash_table_new_full(g_str_hash, g_str_equal, NULL, (GDestroyNotify)jabber_chat_member_free); g_hash_table_insert(js->chats, room_jid, chat); gpresence = gaim_account_get_presence(gc->account); status = gaim_presence_get_active_status(gpresence); gaim_status_to_jabber(status, &state, &msg, &priority); presence = jabber_presence_create(state, msg, priority); full_jid = g_strdup_printf("%s/%s", room_jid, handle); xmlnode_set_attrib(presence, "to", full_jid); g_free(full_jid); g_free(msg); x = xmlnode_new_child(presence, "x"); xmlnode_set_namespace(x, "http://jabber.org/protocol/muc"); if(passwd && *passwd) { xmlnode *password = xmlnode_new_child(x, "password"); xmlnode_insert_data(password, passwd, -1); } jabber_send(js, presence); xmlnode_free(presence); }