void CJabberProto::ResolveTransportNicks(const TCHAR *jid) { // Set all contacts to offline MCONTACT hContact = m_ThreadInfo->resolveContact; if (hContact == NULL) hContact = db_find_first(m_szModuleName); for (; hContact != NULL; hContact = db_find_next(hContact, m_szModuleName)) { if (!getByte(hContact, "IsTransported", 0)) continue; ptrT dbJid( getTStringA(hContact, "jid")); if (dbJid == NULL) continue; ptrT dbNick( getTStringA(hContact, "Nick")); if (dbNick == NULL) continue; TCHAR *p = _tcschr(dbJid, '@'); if (p == NULL) continue; *p = 0; if (!lstrcmp(jid, p+1) && !lstrcmp(dbJid, dbNick)) { *p = '@'; m_ThreadInfo->resolveID = SendGetVcard(dbJid); m_ThreadInfo->resolveContact = hContact; return; } } m_ThreadInfo->resolveID = -1; m_ThreadInfo->resolveContact = NULL; }
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"); }
void CJabberProto::OnUserInfoInit_VCard(WPARAM wParam, LPARAM) { m_vCardUpdates = 0; m_bPhotoChanged = FALSE; m_szPhotoFileName[0] = 0; OPTIONSDIALOGPAGE odp = { 0 }; odp.hInstance = hInst; odp.dwInitParam = (LPARAM)this; odp.flags = ODPF_TCHAR | ODPF_USERINFOTAB | ODPF_DONTTRANSLATE; odp.ptszTitle = m_tszUserName; odp.pfnDlgProc = PersonalDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PERSONAL); odp.ptszTab = LPGENT("General"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = ContactDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_CONTACT); odp.ptszTab = LPGENT("Contacts"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = HomeDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_HOME); odp.ptszTab = LPGENT("Home"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = WorkDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_WORK); odp.ptszTab = LPGENT("Work"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = PhotoDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_PHOTO); odp.ptszTab = LPGENT("Photo"); UserInfo_AddPage(wParam, &odp); odp.pfnDlgProc = NoteDlgProc; odp.pszTemplate = MAKEINTRESOURCEA(IDD_VCARD_NOTE); odp.ptszTab = LPGENT("Note"); UserInfo_AddPage(wParam, &odp); SendGetVcard(m_szJabberJID); }
MCONTACT CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource) { if (jid == NULL || jid[0]=='\0') return NULL; TCHAR *s = NEWTSTR_ALLOCA(jid); TCHAR *q = NULL, *p; // strip resource if present if ((p = _tcschr(s, '@')) != NULL) if ((q = _tcschr(p, '/')) != NULL) *q = '\0'; if (!stripResource && q != NULL) // so that resource is not stripped *q = '/'; // We can't use JabberHContactFromJID() here because of the stripResource option size_t len = _tcslen(s); for (MCONTACT hContact = db_find_first(m_szModuleName); hContact; hContact = db_find_next(hContact, m_szModuleName)) { ptrT jid( getTStringA(hContact, "jid")); if (jid == NULL) continue; TCHAR *p = jid; if (p && _tcslen(p) >= len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) return hContact; } MCONTACT hNewContact = (MCONTACT)CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hNewContact, (LPARAM)m_szModuleName); setTString(hNewContact, "jid", s); if (nick != NULL && *nick != '\0') setTString(hNewContact, "Nick", nick); if (temporary) db_set_b(hNewContact, "CList", "NotOnList", 1); else SendGetVcard(s); debugLog(_T("Create Jabber contact jid=%s, nick=%s"), s, nick); DBCheckIsTransportedContact(s,hNewContact); return hNewContact; }
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 ); }