void __cdecl CJabberProto::OnRenameContact( DBCONTACTWRITESETTING* cws, HANDLE hContact ) { DBVARIANT jid; if ( JGetStringT( hContact, "jid", &jid )) return; JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, jid.ptszVal ); JFreeVariant( &jid ); if ( item == NULL ) return; if ( cws->value.type == DBVT_DELETED ) { TCHAR* nick = ( TCHAR* )JCallService( MS_CLIST_GETCONTACTDISPLAYNAME, ( WPARAM )hContact, GCDNF_NOMYHANDLE | GCDNF_TCHAR ); AddContactToRoster( item->jid, nick, item->group ); mir_free(nick); return; } TCHAR* newNick = sttSettingToTchar( cws ); if ( newNick ) { if ( lstrcmp( item->nick, newNick )) { Log( "Renaming contact " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM " -> " TCHAR_STR_PARAM, item->jid, item->nick, newNick ); AddContactToRoster( item->jid, newNick, item->group ); } mir_free( newNick ); } }
void __cdecl CJabberProto::OnRenameGroup(DBCONTACTWRITESETTING *cws, HANDLE hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT(getTStringA(hContact, "jid"))); if (item == NULL) return; ptrT tszNick(db_get_tsa(hContact, "CList", "MyHandle")); if (tszNick == NULL) tszNick = getTStringA(hContact, "Nick"); if (tszNick == NULL) tszNick = JabberNickFromJID(item->jid); if (tszNick == NULL) return; if (cws->value.type == DBVT_DELETED) { if (item->group != NULL) { debugLogA("Group set to nothing"); AddContactToRoster(item->jid, tszNick, NULL); } } else { TCHAR *p = sttSettingToTchar(cws); if (cws->value.pszVal != NULL && lstrcmp(p, item->group)) { debugLogA("Group set to %S", p); if (p) AddContactToRoster(item->jid, tszNick, p); } mir_free(p); } }
void __cdecl CJabberProto::OnAddContactForever(DBCONTACTWRITESETTING *cws, HANDLE hContact) { if (cws->value.type != DBVT_DELETED && !(cws->value.type == DBVT_BYTE && cws->value.bVal == 0)) return; ptrT jid(getTStringA(hContact, "jid")); if (jid == NULL) return; debugLogA("Add %S permanently to list", jid); ptrT nick(db_get_tsa(hContact, "CList", "MyHandle")); if (nick == NULL) nick = getTStringA(hContact, "Nick"); if (nick == NULL) nick = JabberNickFromJID(jid); if (nick == NULL) return; AddContactToRoster(jid, nick, ptrT(db_get_tsa(hContact, "CList", "Group"))); XmlNode xPresence(_T("presence")); xPresence << XATTR(_T("to"), LPCTSTR(jid)) << XATTR(_T("type"), _T("subscribe")); ptrT myNick(getTStringA(NULL, "Nick")); if (myNick != NULL) xPresence << XCHILD(_T("nick"), LPCTSTR(myNick)) << XATTR(_T("xmlns"), JABBER_FEAT_NICK); m_ThreadInfo->send(xPresence); SendGetVcard(jid); db_unset(hContact, "CList", "Hidden"); }
INT_PTR __cdecl CJabberProto::OnMenuRosterAdd(WPARAM hContact, LPARAM) { if (!hContact) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) ptrT roomID(getTStringA(hContact, "ChatRoomID")); if (roomID == NULL) return 0; if (ListGetItemPtr(LIST_ROSTER, roomID) == NULL) { ptrT group(db_get_tsa(hContact, "CList", "Group")); ptrT nick(getTStringA(hContact, "Nick")); AddContactToRoster(roomID, nick, group); if (m_options.AddRoster2Bookmarks == TRUE) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_BOOKMARK, roomID); if (item == NULL) { item = new JABBER_LIST_ITEM(); item->jid = mir_tstrdup(roomID); item->name = mir_tstrdup(nick); item->nick = getTStringA(hContact, "MyNick"); AddEditBookmark(item); delete item; } } } return 0; }
void __cdecl CJabberProto::OnRenameContact(DBCONTACTWRITESETTING *cws, HANDLE hContact) { JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, ptrT( getTStringA(hContact, "jid"))); if (item == NULL) return; if (cws->value.type == DBVT_DELETED) { TCHAR *nick = pcli->pfnGetContactDisplayName(hContact, GCDNF_NOMYHANDLE); AddContactToRoster(item->jid, nick, item->group); mir_free(nick); return; } ptrT newNick( sttSettingToTchar(cws)); if (newNick && lstrcmp(item->nick, newNick)) { debugLogA("Renaming contact %S: %S -> %S", item->jid, item->nick, newNick); AddContactToRoster(item->jid, newNick, item->group); } }
void __cdecl CJabberProto::OnRenameGroup( DBCONTACTWRITESETTING* cws, HANDLE hContact ) { DBVARIANT jid, dbv; if ( JGetStringT( hContact, "jid", &jid )) return; JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_ROSTER, jid.ptszVal ); JFreeVariant( &jid ); if ( item == NULL ) return; TCHAR* nick; if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv )) { nick = mir_tstrdup( dbv.ptszVal ); JFreeVariant( &dbv ); } else if ( !JGetStringT( hContact, "Nick", &dbv )) { nick = mir_tstrdup( dbv.ptszVal ); JFreeVariant( &dbv ); } else nick = JabberNickFromJID( item->jid ); if ( nick == NULL ) return; if ( cws->value.type == DBVT_DELETED ) { if ( item->group != NULL ) { Log( "Group set to nothing" ); AddContactToRoster( item->jid, nick, NULL ); } } else { TCHAR* p = sttSettingToTchar( cws ); if ( cws->value.pszVal != NULL && lstrcmp( p, item->group )) { Log( "Group set to " TCHAR_STR_PARAM, p ); if ( p ) AddContactToRoster( item->jid, nick, p ); } mir_free( p ); } mir_free( nick ); }
void __cdecl CJabberProto::OnAddContactForever( DBCONTACTWRITESETTING* cws, HANDLE hContact ) { if ( cws->value.type != DBVT_DELETED && !( cws->value.type==DBVT_BYTE && cws->value.bVal==0 )) return; DBVARIANT jid, dbv; if ( JGetStringT( hContact, "jid", &jid )) return; TCHAR *nick; Log( "Add " TCHAR_STR_PARAM " permanently to list", jid.pszVal ); if ( !DBGetContactSettingTString( hContact, "CList", "MyHandle", &dbv )) { nick = mir_tstrdup( dbv.ptszVal ); JFreeVariant( &dbv ); } else if ( !JGetStringT( hContact, "Nick", &dbv )) { nick = mir_tstrdup( dbv.ptszVal ); JFreeVariant( &dbv ); } else nick = JabberNickFromJID( jid.ptszVal ); if ( nick == NULL ) { JFreeVariant( &jid ); return; } if ( !DBGetContactSettingTString( hContact, "CList", "Group", &dbv )) { AddContactToRoster( jid.ptszVal, nick, dbv.ptszVal ); JFreeVariant( &dbv ); } else AddContactToRoster( jid.ptszVal, nick, NULL ); m_ThreadInfo->send( XmlNode( _T("presence")) << XATTR( _T("to"), jid.ptszVal ) << XATTR( _T("type"), _T("subscribe"))); SendGetVcard( jid.ptszVal ); mir_free( nick ); DBDeleteContactSetting( hContact, "CList", "Hidden" ); JFreeVariant( &jid ); }