void GaduContactListService::importContactList() { ImportReply.truncate(0); if (-1 == gg_userlist_request(Protocol->gaduSession(), GG_USERLIST_GET, 0)) emit contactListImported(false, ContactList()); }
void GaduContactListService::exportContactList(ContactList contacts) { QString contactsString = GaduListHelper::contactListToString(Protocol->account(), contacts); kdebugmf(KDEBUG_NETWORK|KDEBUG_INFO, "\n%s\n", unicode2cp(contactsString).data()); if (-1 == gg_userlist_request(Protocol->gaduSession(), GG_USERLIST_PUT, unicode2cp(contactsString))) emit contactListExported(false); }
void message_get_roster(struct stream_s *stream,const char *from, const char *to, const char *args, xmlnode msg){ Session *s; s=session_get_by_jid(from,stream,0); if(!s || !s->ggs){ message_send(stream,to,from,1,_("Log in first..."),0); return; } message_send(stream,to,from,1,_("Receiving roster..."),0); gg_userlist_request(s->ggs, GG_USERLIST_GET, NULL); }
void GaduSession::requestContacts() { if ( !session_ || session_->state != GG_STATE_CONNECTED ) { kdDebug(14100) <<" you need to be connected to send " << endl; return; } if ( gg_userlist_request( session_, GG_USERLIST_GET, NULL ) == -1 ) { kdDebug(14100) <<" userlist export ERROR " << endl; return; } kdDebug( 14100 ) << "Contacts list import..started " << endl; }
gboolean on_userlist_import_page_1_next (GnomeDruidPage * druidpage, GtkWidget * widget, gpointer user_data) { GtkWidget *radio_import_server, *radio_import_file; GnomeDruid *druid = GNOME_DRUID (glade_xml_get_widget (gladexml_import_userlist, "ImportUserlistDruid")); GnomeDruidPage *page_last = GNOME_DRUID_PAGE (glade_xml_get_widget (gladexml_import_userlist, "userlist_import_page_last")); radio_import_server = glade_xml_get_widget (gladexml_import_userlist, "RadioImportServer"); radio_import_file = glade_xml_get_widget (gladexml_import_userlist, "RadioImportFile"); g_assert (radio_import_file); if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (radio_import_server))) { GtkWidget *progress_window; if (!gnomegadu_gadugadu_session) { GtkDialog *msgdialog = gtk_message_dialog_new_with_markup (NULL, GTK_DIALOG_DESTROY_WITH_PARENT, GTK_MESSAGE_ERROR, GTK_BUTTONS_CLOSE, "<span weight=\"bold\"size=\"larger\">Brak połączenia</span>\n\nPołącz się z siecią Gadu-Gadu i spróbuj ponownie."); gtk_dialog_run (GTK_DIALOG (msgdialog)); gtk_widget_destroy (GTK_WIDGET (msgdialog)); return TRUE; } gladexml_import_userlist_progress = glade_xml_new (PACKAGE_DATA_DIR "/gnomegadu.glade", "ImportUserlistServerProgressWindow", NULL); glade_xml_signal_autoconnect (gladexml_import_userlist_progress); g_assert (gladexml_import_userlist_progress); progress_window = glade_xml_get_widget (gladexml_import_userlist_progress, "ImportUserlistServerProgressWindow"); g_assert(progress_window); gtk_widget_show_all (GTK_WIDGET(progress_window)); gg_userlist_request (gnomegadu_gadugadu_session, GG_USERLIST_GET, NULL); gnome_druid_set_page (druid, page_last); gnome_druid_set_buttons_sensitive (druid, TRUE, FALSE, TRUE, FALSE); gnome_druid_set_show_finish (druid, TRUE); } else { //gtk_file_chooser_get_filename () //gnomegadu_import_userlist_from_file(); } return FALSE; }
void GaduSession::exportContactsOnServer( GaduContactsList* contactsList ) { QCString plist; if ( !session_ || session_->state != GG_STATE_CONNECTED ) { kdDebug( 14100 ) << "you need to connect to export Contacts list " << endl; return; } plist = textcodec->fromUnicode( contactsList->asString() ); kdDebug(14100) <<"--------------------userlists\n" << plist << endl; kdDebug(14100) << "----------------------------" << endl; if ( gg_userlist_request( session_, GG_USERLIST_PUT, plist.data() ) == -1 ) { kdDebug( 14100 ) << "export contact list failed " << endl; return; } kdDebug( 14100 ) << "Contacts list export..started " << endl; }
int session_io_handler(Session *s){ struct gg_event *event; char *jid,*str; int chat; GIOCondition condition=s->g_pollfd.revents; time_t timestamp; gboolean state; user_load_locale(s->user); debug(L_("Checking error conditions...")); if (condition&(G_IO_ERR|G_IO_NVAL)){ if (condition&G_IO_ERR) g_warning(N_("Error on connection for %s, GGid: %i"),s->jid,s->ggs->uin); if (condition&G_IO_HUP){ g_warning(N_("Hangup on connection for %s, GGid: %i"),s->jid,s->ggs->uin); return session_error(s); } if (condition&G_IO_NVAL) g_warning(N_("Invalid channel on connection for %s"),s->jid); session_broken(s); return FALSE; } debug(L_("watching fd (gg_debug_level=%i)..."),gg_debug_level); event=gg_watch_fd(s->ggs); if (!event){ g_warning(N_("Connection broken. Session of %s, GGid: %i"),s->jid,s->ggs->uin); return session_error(s); } switch(event->type){ case GG_EVENT_DISCONNECT: g_warning(N_("Server closed connection of %s, GGid: %i"),s->jid,s->ggs->uin); session_error(s); gg_event_free(event); return FALSE; case GG_EVENT_CONN_FAILED: g_message(N_("Login failed (%d:%s) for %s, GGid: %i"), event->event.failure, (event->event.failure>GG_FAILURE_NUM_REASONS||event->event.failure<1)?"-UNKNOWN-":gg_failure_reason[event->event.failure-1], s->jid, s->ggs->uin); if (s->req_id) jabber_iq_send_error(s->s,s->jid,NULL,s->req_id,401,_("Unauthorized")); else { str=g_strdup(from_utf8(gg_failure_reason_txt[event->event.failure-1])); presence_send(s->s,NULL,s->user->jid,0,NULL,str,0); g_free(str); } state = FALSE; if (!s->req_id) switch(event->event.failure){ case GG_FAILURE_RESOLVING: case GG_FAILURE_CONNECTING: case GG_FAILURE_INVALID: case GG_FAILURE_READING: case GG_FAILURE_WRITING: case GG_FAILURE_TLS: state = session_try_next(s); default: break; } if (state) { s->connected=0; session_schedule_reconnect(s); } else session_remove(s); gg_event_free(event); return FALSE; case GG_EVENT_CONN_SUCCESS: g_message(L_("Login succeed for %s, GGid: %i"),s->jid,s->ggs->uin); if (s->req_id) jabber_iq_send_result(s->s,s->jid,NULL,s->req_id,NULL); if (s->req_id){ g_free(s->req_id); s->req_id=NULL; } if (s->query){ xmlnode_free(s->query); s->query=NULL; } if (!s->user->confirmed){ s->user->confirmed=1; user_save(s->user); } s->connected=1; session_send_status(s); session_send_notify(s); presence_send(s->s,NULL,s->user->jid,s->user->invisible?-1:1,NULL,s->gg_status_descr,0); if (s->timeout_func) g_source_remove(s->timeout_func); s->timeout_func=NULL; if (s->ping_timeout_func) g_source_remove(s->ping_timeout_func); s->ping_timeout_func=g_timeout_add(ping_interval*1000,session_ping,s); if (s->pubdir_change){ add_request(RT_CHANGE,s->jid,NULL,s->req_id, NULL,s->pubdir_change,s->s); gg_pubdir50_free(s->pubdir_change); s->pubdir_change=NULL; } if (s->get_roster){ gg_userlist_request(s->ggs, GG_USERLIST_GET, NULL); } break; case GG_EVENT_NOTIFY: session_event_notify(s,event); break; case GG_EVENT_NOTIFY_DESCR: session_event_notify_descr(s,event); break; case GG_EVENT_NOTIFY60: session_event_notify60(s,event); break; case GG_EVENT_STATUS: session_event_status(s, event->event.status.status, event->event.status.uin, event->event.status.descr, 0,0,0,0); break; case GG_EVENT_STATUS60: session_event_status(s, event->event.status60.status, event->event.status60.uin, event->event.status60.descr, 1, event->event.status60.remote_ip, event->event.status60.remote_port, event->event.status60.version); break; case GG_EVENT_MSG: if (event->event.msg.recipients_count>1){ debug(L_("Dropped conference message: sender: %i class: %i time: %lu"), event->event.msg.sender, event->event.msg.msgclass, (unsigned long)event->event.msg.time); break; } gg_messages_in++; debug(L_("Message: sender: %i class: %i time: %lu"), event->event.msg.sender, event->event.msg.msgclass, (unsigned long)event->event.msg.time); if (event->event.msg.sender==0){ if (!user_sys_msg_received(s->user,event->event.msg.msgclass)) break; if (ignore_system_messages == ISM_IGNORE_ALL) break; if (ignore_system_messages == ISM_IGNORE_HTML && strstr((const char *)event->event.msg.message, "<HTML>")) break; timestamp=event->event.msg.time; str=g_strdup_printf(_("GG System message #%i"), event->event.msg.msgclass); message_send_subject(s->s,jid, s->user->jid, str, string_from_gg((const char *)event->event.msg.message), timestamp); g_free(str); break; } else{ Contact *c=user_get_contact(s->user, event->event.msg.sender,0); if ((!c && s->user->ignore_unknown) || (c && c->ignored)) { debug(L_("Ignoring the message.")); break; } jid=jid_build_full(event->event.msg.sender); if ((event->event.msg.msgclass&GG_CLASS_CHAT)!=0) chat=1; else chat=0; } if ((event->event.msg.msgclass&GG_CLASS_QUEUED)!=0){ timestamp=event->event.msg.time; } else timestamp=0; if(event->event.msg.formats_length>0) message_send_rich(s->s,jid,s->user->jid,chat, (char *)event->event.msg.message,timestamp, event->event.msg.formats_length,(void *)event->event.msg.formats); else message_send(s->s,jid,s->user->jid,chat, string_from_gg((const char *)event->event.msg.message),timestamp); g_free(jid); break; case GG_EVENT_PONG: s->waiting_for_pong=FALSE; if (s->ping_timer){ g_timer_stop(s->ping_timer); debug(L_("Pong! ping time: %fs"), g_timer_elapsed(s->ping_timer,NULL)); } if (s->timeout_func) g_source_remove(s->timeout_func); s->timeout_func=NULL; break; case GG_EVENT_PUBDIR50_SEARCH_REPLY: request_response_search(event); break; case GG_EVENT_PUBDIR50_WRITE: request_response_write(event); break; case GG_EVENT_ACK: debug("GG_EVENT_ACK"); break; case GG_EVENT_NONE: debug("GG_EVENT_NONE"); break; case GG_EVENT_USERLIST: if(event->event.userlist.type==GG_USERLIST_GET_REPLY) get_roster_done(s,event); else g_warning(N_("Wrong gg userlist type: %i"),event->event.userlist.type); break; default: g_warning(N_("Unknown GG event: %i"),event->type); break; } session_setup_g_source(s); gg_event_free(event); debug(L_("io handler done...")); return FALSE; }