diff options
author | George Hazan <george.hazan@gmail.com> | 2012-11-15 21:18:48 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-11-15 21:18:48 +0000 |
commit | 7ebaebba8520e457bf374ca245f52332fbb008be (patch) | |
tree | 55cf960e4981d9413befb1bf275a3fd067bf2534 /protocols/JabberG/src/jabber_misc.cpp | |
parent | 8353de363fc22940685b334cbb38c0378e9c1b71 (diff) |
bye-bye old coding style in Jabber
git-svn-id: http://svn.miranda-ng.org/main/trunk@2322 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/JabberG/src/jabber_misc.cpp')
-rw-r--r-- | protocols/JabberG/src/jabber_misc.cpp | 366 |
1 files changed, 183 insertions, 183 deletions
diff --git a/protocols/JabberG/src/jabber_misc.cpp b/protocols/JabberG/src/jabber_misc.cpp index e13c0d450d..5b1fe0da26 100644 --- a/protocols/JabberG/src/jabber_misc.cpp +++ b/protocols/JabberG/src/jabber_misc.cpp @@ -1,14 +1,14 @@ /*
Jabber Protocol Plugin for Miranda IM
-Copyright ( C ) 2002-04 Santithorn Bunchua
-Copyright ( C ) 2005-12 George Hazan
-Copyright ( C ) 2007 Maxim Mluhov
+Copyright (C) 2002-04 Santithorn Bunchua
+Copyright (C) 2005-12 George Hazan
+Copyright (C) 2007 Maxim Mluhov
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
-of the License, or ( at your option ) any later version.
+of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -31,14 +31,14 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ///////////////////////////////////////////////////////////////////////////////
// JabberAddContactToRoster() - adds a contact to the roster
-void CJabberProto::AddContactToRoster( const TCHAR* jid, const TCHAR* nick, const TCHAR* grpName )
+void CJabberProto::AddContactToRoster(const TCHAR *jid, const TCHAR *nick, const TCHAR *grpName)
{
- XmlNodeIq iq( _T("set"), SerialNext());
- HXML query = iq << XQUERY( _T(JABBER_FEAT_IQ_ROSTER))
- << XCHILD( _T("item")) << XATTR( _T("jid"), jid ) << XATTR( _T("name"), nick );
- if ( grpName )
- query << XCHILD( _T("group"), grpName );
- m_ThreadInfo->send( iq );
+ XmlNodeIq iq(_T("set"), SerialNext());
+ HXML query = iq << XQUERY(_T(JABBER_FEAT_IQ_ROSTER))
+ << XCHILD(_T("item")) << XATTR(_T("jid"), jid) << XATTR(_T("name"), nick);
+ if (grpName)
+ query << XCHILD(_T("group"), grpName);
+ m_ThreadInfo->send(iq);
}
///////////////////////////////////////////////////////////////////////////////
@@ -46,198 +46,198 @@ void CJabberProto::AddContactToRoster( const TCHAR* jid, const TCHAR* nick, cons void JabberChatDllError()
{
- MessageBox( NULL,
- TranslateT( "CHAT plugin is required for conferences. Install it before chatting" ),
- TranslateT( "Jabber Error" ), MB_OK|MB_SETFOREGROUND );
+ MessageBox(NULL,
+ TranslateT("CHAT plugin is required for conferences. Install it before chatting"),
+ TranslateT("Jabber Error"), MB_OK|MB_SETFOREGROUND);
}
///////////////////////////////////////////////////////////////////////////////
// JabberCompareJids
-int JabberCompareJids( const TCHAR* jid1, const TCHAR* jid2 )
+int JabberCompareJids(const TCHAR *jid1, const TCHAR *jid2)
{
- if ( !lstrcmpi( jid1, jid2 ))
+ if ( !lstrcmpi(jid1, jid2))
return 0;
// match only node@domain part
TCHAR szTempJid1[ JABBER_MAX_JID_LEN ], szTempJid2[ JABBER_MAX_JID_LEN ];
return lstrcmpi(
- JabberStripJid( jid1, szTempJid1, SIZEOF(szTempJid1)),
- JabberStripJid( jid2, szTempJid2, SIZEOF(szTempJid2)));
+ JabberStripJid(jid1, szTempJid1, SIZEOF(szTempJid1)),
+ JabberStripJid(jid2, szTempJid2, SIZEOF(szTempJid2)));
}
///////////////////////////////////////////////////////////////////////////////
// JabberContactListCreateGroup()
-static void JabberContactListCreateClistGroup( TCHAR* groupName )
+static void JabberContactListCreateClistGroup(TCHAR* groupName)
{
char str[33];
int i;
DBVARIANT dbv;
- for ( i=0;;i++ ) {
- _itoa( i, str, 10 );
- if ( DBGetContactSettingTString( NULL, "CListGroups", str, &dbv ))
+ for (i=0;;i++) {
+ _itoa(i, str, 10);
+ if (DBGetContactSettingTString(NULL, "CListGroups", str, &dbv))
break;
TCHAR* name = dbv.ptszVal;
- if ( name[0]!='\0' && !_tcscmp( name+1, groupName )) {
+ if (name[0]!='\0' && !_tcscmp(name+1, groupName)) {
// Already exists, no need to create
- JFreeVariant( &dbv );
+ db_free(&dbv);
return;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- // Create new group with id = i ( str is the text representation of i )
+ // Create new group with id = i (str is the text representation of i)
TCHAR newName[128];
newName[0] = 1 | GROUPF_EXPANDED;
- _tcsncpy( newName+1, groupName, SIZEOF( newName )-1 );
- newName[ SIZEOF( newName )-1] = '\0';
- DBWriteContactSettingTString( NULL, "CListGroups", str, newName );
- CallService( MS_CLUI_GROUPADDED, i+1, 0 );
+ _tcsncpy(newName+1, groupName, SIZEOF(newName)-1);
+ newName[ SIZEOF(newName)-1] = '\0';
+ db_set_ts(NULL, "CListGroups", str, newName);
+ CallService(MS_CLUI_GROUPADDED, i+1, 0);
}
-void JabberContactListCreateGroup( TCHAR* groupName )
+void JabberContactListCreateGroup(TCHAR* groupName)
{
TCHAR name[128], *p;
- if ( groupName==NULL || groupName[0]=='\0' || groupName[0]=='\\' ) return;
+ if (groupName==NULL || groupName[0]=='\0' || groupName[0]=='\\') return;
- _tcsncpy( name, groupName, SIZEOF( name ));
- name[ SIZEOF( name )-1] = '\0';
- for ( p=name; *p!='\0'; p++ ) {
- if ( *p == '\\' ) {
+ _tcsncpy(name, groupName, SIZEOF(name));
+ name[ SIZEOF(name)-1] = '\0';
+ for (p=name; *p!='\0'; p++) {
+ if (*p == '\\') {
*p = '\0';
- JabberContactListCreateClistGroup( name );
+ JabberContactListCreateClistGroup(name);
*p = '\\';
}
}
- JabberContactListCreateClistGroup( name );
+ JabberContactListCreateClistGroup(name);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBAddAuthRequest()
-void CJabberProto::DBAddAuthRequest( const TCHAR* jid, const TCHAR* nick )
+void CJabberProto::DBAddAuthRequest(const TCHAR *jid, const TCHAR *nick)
{
- HANDLE hContact = DBCreateContact( jid, NULL, TRUE, TRUE );
- JDeleteSetting( hContact, "Hidden" );
- //JSetStringT( hContact, "Nick", nick );
+ HANDLE hContact = DBCreateContact(jid, NULL, TRUE, TRUE);
+ JDeleteSetting(hContact, "Hidden");
+ //JSetStringT(hContact, "Nick", nick);
- char* szJid = mir_utf8encodeT( jid );
- char* szNick = mir_utf8encodeT( nick );
+ char* szJid = mir_utf8encodeT(jid);
+ char* szNick = mir_utf8encodeT(nick);
//blob is: uin(DWORD), hContact(DWORD), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ)
- //blob is: 0( DWORD ), hContact(DWORD), nick( ASCIIZ ), ""( ASCIIZ ), ""( ASCIIZ ), email( ASCIIZ ), ""( ASCIIZ )
+ //blob is: 0(DWORD), hContact(DWORD), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ)
DBEVENTINFO dbei = { sizeof(DBEVENTINFO) };
dbei.szModule = m_szModuleName;
- dbei.timestamp = ( DWORD )time( NULL );
+ dbei.timestamp = (DWORD)time(NULL);
dbei.flags = DBEF_UTF;
dbei.eventType = EVENTTYPE_AUTHREQUEST;
- dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + strlen( szNick ) + strlen( szJid ) + 5);
+ dbei.cbBlob = (DWORD)(sizeof(DWORD)*2 + strlen(szNick) + strlen(szJid) + 5);
PBYTE pCurBlob = dbei.pBlob = (PBYTE)mir_alloc(dbei.cbBlob);
*((PDWORD)pCurBlob) = 0; pCurBlob += sizeof(DWORD);
*((PDWORD)pCurBlob) = (DWORD)hContact; pCurBlob += sizeof(DWORD);
- strcpy(( char* )pCurBlob, szNick ); pCurBlob += strlen( szNick )+1;
+ strcpy((char*)pCurBlob, szNick); pCurBlob += strlen(szNick)+1;
*pCurBlob = '\0'; pCurBlob++; //firstName
*pCurBlob = '\0'; pCurBlob++; //lastName
- strcpy(( char* )pCurBlob, szJid ); pCurBlob += strlen( szJid )+1;
+ strcpy((char*)pCurBlob, szJid); pCurBlob += strlen(szJid)+1;
*pCurBlob = '\0'; //reason
- CallService( MS_DB_EVENT_ADD, ( WPARAM ) ( HANDLE ) NULL, ( LPARAM )&dbei );
- Log( "Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid );
+ CallService(MS_DB_EVENT_ADD, (WPARAM)(HANDLE)NULL, (LPARAM)&dbei);
+ Log("Setup DBAUTHREQUEST with nick='%s' jid='%s'", szNick, szJid);
- mir_free( szJid );
- mir_free( szNick );
+ mir_free(szJid);
+ mir_free(szNick);
}
///////////////////////////////////////////////////////////////////////////////
// JabberDBCreateContact()
-HANDLE CJabberProto::DBCreateContact( const TCHAR* jid, const TCHAR* nick, BOOL temporary, BOOL stripResource )
+HANDLE CJabberProto::DBCreateContact(const TCHAR *jid, const TCHAR *nick, BOOL temporary, BOOL stripResource)
{
TCHAR* s, *p, *q;
size_t len;
- char* szProto;
+ char *szProto;
- if ( jid==NULL || jid[0]=='\0' )
+ if (jid==NULL || jid[0]=='\0')
return NULL;
- s = mir_tstrdup( jid );
+ s = mir_tstrdup(jid);
q = NULL;
// strip resource if present
- if (( p = _tcschr( s, '@' )) != NULL )
- if (( q = _tcschr( p, '/' )) != NULL )
+ if ((p = _tcschr(s, '@')) != NULL)
+ if ((q = _tcschr(p, '/')) != NULL)
*q = '\0';
- if ( !stripResource && q!=NULL ) // so that resource is not stripped
+ if ( !stripResource && q!=NULL) // so that resource is not stripped
*q = '/';
- len = _tcslen( s );
+ len = _tcslen(s);
// We can't use JabberHContactFromJID() here because of the stripResource option
- HANDLE hContact = ( HANDLE ) db_find_first();
- while ( hContact != NULL ) {
- szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( szProto!=NULL && !strcmp( m_szModuleName, szProto )) {
+ HANDLE hContact = (HANDLE)db_find_first();
+ while (hContact != NULL) {
+ szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (szProto!=NULL && !strcmp(m_szModuleName, szProto)) {
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
p = dbv.ptszVal;
- if ( p && _tcslen( p )>=len && ( p[len]=='\0'||p[len]=='/' ) && !_tcsnicmp( p, s, len )) {
- JFreeVariant( &dbv );
+ if (p && _tcslen(p)>=len && (p[len]=='\0'||p[len]=='/') && !_tcsnicmp(p, s, len)) {
+ db_free(&dbv);
break;
}
- JFreeVariant( &dbv );
+ db_free(&dbv);
} }
hContact = db_find_next(hContact);
}
- if ( hContact == NULL ) {
- hContact = ( HANDLE ) CallService( MS_DB_CONTACT_ADD, 0, 0 );
- CallService( MS_PROTO_ADDTOCONTACT, ( WPARAM ) hContact, ( LPARAM )m_szModuleName );
- JSetStringT( hContact, "jid", s );
- if ( nick != NULL && *nick != '\0' )
- JSetStringT( hContact, "Nick", nick );
- if ( temporary )
- DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 );
+ if (hContact == NULL) {
+ hContact = (HANDLE)CallService(MS_DB_CONTACT_ADD, 0, 0);
+ CallService(MS_PROTO_ADDTOCONTACT, (WPARAM)hContact, (LPARAM)m_szModuleName);
+ JSetStringT(hContact, "jid", s);
+ if (nick != NULL && *nick != '\0')
+ JSetStringT(hContact, "Nick", nick);
+ if (temporary)
+ db_set_b(hContact, "CList", "NotOnList", 1);
else
- SendGetVcard( s );
- Log( "Create Jabber contact jid=" TCHAR_STR_PARAM ", nick=" TCHAR_STR_PARAM, s, nick );
+ SendGetVcard(s);
+ Log("Create Jabber contact jid=" TCHAR_STR_PARAM ", nick=" TCHAR_STR_PARAM, s, nick);
DBCheckIsTransportedContact(s,hContact);
}
- mir_free( s );
+ mir_free(s);
return hContact;
}
BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType)
{
- if ( !hContact )
+ if ( !hContact)
return FALSE;
- switch ( btEventType ) {
+ switch (btEventType) {
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBE:
case JABBER_DB_EVENT_PRESENCE_SUBSCRIBED:
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBE:
case JABBER_DB_EVENT_PRESENCE_UNSUBSCRIBED:
- if ( !m_options.LogPresence )
+ if ( !m_options.LogPresence)
return FALSE;
break;
case JABBER_DB_EVENT_PRESENCE_ERROR:
- if ( !m_options.LogPresenceErrors )
+ if ( !m_options.LogPresenceErrors)
return FALSE;
break;
}
DBEVENTINFO dbei;
- dbei.cbSize = sizeof( dbei );
+ dbei.cbSize = sizeof(dbei);
dbei.pBlob = &btEventType;
- dbei.cbBlob = sizeof( btEventType );
+ dbei.cbBlob = sizeof(btEventType);
dbei.eventType = JABBER_DB_EVENT_TYPE_PRESENCE;
dbei.flags = DBEF_READ;
- dbei.timestamp = time( NULL );
+ dbei.timestamp = time(NULL);
dbei.szModule = m_szModuleName;
- CallService( MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei );
+ CallService(MS_DB_EVENT_ADD, (WPARAM)hContact, (LPARAM)&dbei);
return TRUE;
}
@@ -248,117 +248,117 @@ BOOL CJabberProto::AddDbPresenceEvent(HANDLE hContact, BYTE btEventType) static HANDLE hJabberAvatarsFolder = NULL;
static bool bInitDone = false;
-void CJabberProto::InitCustomFolders( void )
+void CJabberProto::InitCustomFolders(void)
{
- if ( bInitDone )
+ if (bInitDone)
return;
bInitDone = true;
- if ( ServiceExists( MS_FOLDERS_REGISTER_PATH )) {
+ if (ServiceExists(MS_FOLDERS_REGISTER_PATH)) {
TCHAR AvatarsFolder[MAX_PATH];
- mir_sntprintf( AvatarsFolder, SIZEOF( AvatarsFolder ), _T("%%miranda_avatarcache%%\\Jabber"));
- hJabberAvatarsFolder = FoldersRegisterCustomPathT( m_szModuleName, "Avatars", AvatarsFolder ); // title!!!!!!!!!!!
+ mir_sntprintf(AvatarsFolder, SIZEOF(AvatarsFolder), _T("%%miranda_avatarcache%%\\Jabber"));
+ hJabberAvatarsFolder = FoldersRegisterCustomPathT(m_szModuleName, "Avatars", AvatarsFolder); // title!!!!!!!!!!!
} }
-void CJabberProto::GetAvatarFileName( HANDLE hContact, TCHAR* pszDest, size_t cbLen )
+void CJabberProto::GetAvatarFileName(HANDLE hContact, TCHAR* pszDest, size_t cbLen)
{
size_t tPathLen;
- TCHAR* path = ( TCHAR* )alloca( cbLen * sizeof( TCHAR ));
+ TCHAR* path = (TCHAR*)alloca(cbLen * sizeof(TCHAR));
InitCustomFolders();
- if ( hJabberAvatarsFolder == NULL || FoldersGetCustomPathT( hJabberAvatarsFolder, path, (int)cbLen, _T(""))) {
- TCHAR *tmpPath = Utils_ReplaceVarsT( _T("%miranda_avatarcache%"));
- tPathLen = mir_sntprintf( pszDest, cbLen, _T("%s\\Jabber"), tmpPath );
+ if (hJabberAvatarsFolder == NULL || FoldersGetCustomPathT(hJabberAvatarsFolder, path, (int)cbLen, _T(""))) {
+ TCHAR *tmpPath = Utils_ReplaceVarsT(_T("%miranda_avatarcache%"));
+ tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s\\Jabber"), tmpPath);
mir_free(tmpPath);
}
- else tPathLen = mir_sntprintf( pszDest, cbLen, _T("%s"), path );
+ else tPathLen = mir_sntprintf(pszDest, cbLen, _T("%s"), path);
- DWORD dwAttributes = GetFileAttributes( pszDest );
- if ( dwAttributes == 0xffffffff || ( dwAttributes & FILE_ATTRIBUTE_DIRECTORY ) == 0 )
- CallService( MS_UTILS_CREATEDIRTREET, 0, ( LPARAM )pszDest );
+ DWORD dwAttributes = GetFileAttributes(pszDest);
+ if (dwAttributes == 0xffffffff || (dwAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0)
+ CallService(MS_UTILS_CREATEDIRTREET, 0, (LPARAM)pszDest);
pszDest[ tPathLen++ ] = '\\';
char* szFileType = NULL;
- switch( JGetByte( hContact, "AvatarType", PA_FORMAT_PNG )) {
+ switch(JGetByte(hContact, "AvatarType", PA_FORMAT_PNG)) {
case PA_FORMAT_JPEG: szFileType = "jpg"; break;
case PA_FORMAT_PNG: szFileType = "png"; break;
case PA_FORMAT_GIF: szFileType = "gif"; break;
case PA_FORMAT_BMP: szFileType = "bmp"; break;
}
- if ( hContact != NULL ) {
+ if (hContact != NULL) {
char str[ 256 ];
DBVARIANT dbv;
- if ( !JGetStringUtf( hContact, "jid", &dbv )) {
- strncpy( str, dbv.pszVal, sizeof str );
+ if ( !JGetStringUtf(hContact, "jid", &dbv)) {
+ strncpy(str, dbv.pszVal, sizeof str);
str[ sizeof(str)-1 ] = 0;
- JFreeVariant( &dbv );
+ db_free(&dbv);
}
- else _i64toa(( LONG_PTR )hContact, str, 10 );
+ else _i64toa((LONG_PTR)hContact, str, 10);
- char* hash = JabberSha1( str );
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T(".") _T(TCHAR_STR_PARAM), hash, szFileType );
- mir_free( hash );
+ char* hash = JabberSha1(str);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T(".") _T(TCHAR_STR_PARAM), hash, szFileType);
+ mir_free(hash);
}
- else if ( m_ThreadInfo != NULL ) {
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
- m_ThreadInfo->username, m_ThreadInfo->server, szFileType );
+ else if (m_ThreadInfo != NULL) {
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T("%s@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
+ m_ThreadInfo->username, m_ThreadInfo->server, szFileType);
}
else {
DBVARIANT dbv1, dbv2;
- BOOL res1 = DBGetContactSettingString( NULL, m_szModuleName, "LoginName", &dbv1 );
- BOOL res2 = DBGetContactSettingString( NULL, m_szModuleName, "LoginServer", &dbv2 );
- mir_sntprintf( pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T("@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
+ BOOL res1 = DBGetContactSettingString(NULL, m_szModuleName, "LoginName", &dbv1);
+ BOOL res2 = DBGetContactSettingString(NULL, m_szModuleName, "LoginServer", &dbv2);
+ mir_sntprintf(pszDest + tPathLen, MAX_PATH - tPathLen, _T(TCHAR_STR_PARAM) _T("@") _T(TCHAR_STR_PARAM) _T(" avatar.") _T(TCHAR_STR_PARAM),
res1 ? "noname" : dbv1.pszVal,
res2 ? m_szModuleName : dbv2.pszVal,
- szFileType );
- if (!res1) JFreeVariant( &dbv1 );
- if (!res2) JFreeVariant( &dbv2 );
+ szFileType);
+ if ( !res1) db_free(&dbv1);
+ if ( !res2) db_free(&dbv2);
}
}
///////////////////////////////////////////////////////////////////////////////
// JabberResolveTransportNicks - massive vcard update
-void CJabberProto::ResolveTransportNicks( const TCHAR* jid )
+void CJabberProto::ResolveTransportNicks(const TCHAR *jid)
{
// Set all contacts to offline
HANDLE hContact = m_ThreadInfo->resolveContact;
- if ( hContact == NULL )
- hContact = ( HANDLE ) db_find_first();
+ if (hContact == NULL)
+ hContact = (HANDLE)db_find_first();
- for ( ; hContact != NULL; hContact = db_find_next(hContact)) {
- char* szProto = ( char* )CallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 );
- if ( lstrcmpA( szProto, m_szModuleName ))
+ for (; hContact != NULL; hContact = db_find_next(hContact)) {
+ char *szProto = (char*)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0);
+ if (lstrcmpA(szProto, m_szModuleName))
continue;
- if ( !JGetByte( hContact, "IsTransported", 0 ))
+ if ( !JGetByte(hContact, "IsTransported", 0))
continue;
DBVARIANT dbv, nick;
- if ( JGetStringT( hContact, "jid", &dbv ))
+ if (JGetStringT(hContact, "jid", &dbv))
continue;
- if ( JGetStringT( hContact, "Nick", &nick )) {
- JFreeVariant( &dbv );
+ if (JGetStringT(hContact, "Nick", &nick)) {
+ db_free(&dbv);
continue;
}
- TCHAR* p = _tcschr( dbv.ptszVal, '@' );
- if ( p ) {
+ TCHAR* p = _tcschr(dbv.ptszVal, '@');
+ if (p) {
*p = 0;
- if ( !lstrcmp( jid, p+1 ) && !lstrcmp( dbv.ptszVal, nick.ptszVal )) {
+ if ( !lstrcmp(jid, p+1) && !lstrcmp(dbv.ptszVal, nick.ptszVal)) {
*p = '@';
- m_ThreadInfo->resolveID = SendGetVcard( dbv.ptszVal );
+ m_ThreadInfo->resolveID = SendGetVcard(dbv.ptszVal);
m_ThreadInfo->resolveContact = hContact;
- JFreeVariant( &dbv );
- JFreeVariant( &nick );
+ db_free(&dbv);
+ db_free(&nick);
return;
} }
- JFreeVariant( &dbv );
- JFreeVariant( &nick );
+ db_free(&dbv);
+ db_free(&nick);
}
m_ThreadInfo->resolveID = -1;
@@ -368,14 +368,14 @@ void CJabberProto::ResolveTransportNicks( const TCHAR* jid ) ///////////////////////////////////////////////////////////////////////////////
// JabberSetServerStatus()
-void CJabberProto::SetServerStatus( int iNewStatus )
+void CJabberProto::SetServerStatus(int iNewStatus)
{
- if ( !m_bJabberOnline )
+ if ( !m_bJabberOnline)
return;
// change status
int oldStatus = m_iStatus;
- switch ( iNewStatus ) {
+ switch (iNewStatus) {
case ID_STATUS_ONLINE:
case ID_STATUS_NA:
case ID_STATUS_FREECHAT:
@@ -395,12 +395,12 @@ void CJabberProto::SetServerStatus( int iNewStatus ) return;
}
- if ( m_iStatus == oldStatus )
+ if (m_iStatus == oldStatus)
return;
// send presence update
- SendPresence( m_iStatus, true );
- JSendBroadcast( NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, ( HANDLE ) oldStatus, m_iStatus );
+ SendPresence(m_iStatus, true);
+ JSendBroadcast(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE)oldStatus, m_iStatus);
}
// Process a string, and double all % characters, according to chat.dll's restrictions
@@ -408,18 +408,18 @@ void CJabberProto::SetServerStatus( int iNewStatus ) TCHAR* EscapeChatTags(TCHAR* pszText)
{
int nChars = 0;
- for ( TCHAR* p = pszText; ( p = _tcschr( p, '%' )) != NULL; p++ )
+ for (TCHAR* p = pszText; (p = _tcschr(p, '%')) != NULL; p++)
nChars++;
- if ( nChars == 0 )
- return mir_tstrdup( pszText );
+ if (nChars == 0)
+ return mir_tstrdup(pszText);
- TCHAR* pszNewText = (TCHAR*)mir_alloc( sizeof(TCHAR)*(_tcslen( pszText ) + 1 + nChars )), *s, *d;
- if ( pszNewText == NULL )
- return mir_tstrdup( pszText );
+ TCHAR* pszNewText = (TCHAR*)mir_alloc(sizeof(TCHAR)*(_tcslen(pszText) + 1 + nChars)), *s, *d;
+ if (pszNewText == NULL)
+ return mir_tstrdup(pszText);
- for ( s = pszText, d = pszNewText; *s; s++ ) {
- if ( *s == '%' )
+ for (s = pszText, d = pszNewText; *s; s++) {
+ if (*s == '%')
*d++ = '%';
*d++ = *s;
}
@@ -430,8 +430,8 @@ TCHAR* EscapeChatTags(TCHAR* pszText) TCHAR* UnEscapeChatTags(TCHAR* str_in)
{
TCHAR* s = str_in, *d = str_in;
- while ( *s ) {
- if ( *s == '%' && s[1] == '%' )
+ while (*s) {
+ if (*s == '%' && s[1] == '%')
s++;
*d++ = *s++;
}
@@ -460,7 +460,7 @@ static sttCapsNodeToName_Map[] = void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item)
{
HANDLE hContact = HContactFromJID(item->jid);
- if (!hContact)
+ if ( !hContact)
return;
Log("JabberUpdateMirVer: for jid " TCHAR_STR_PARAM, item->jid);
@@ -473,17 +473,17 @@ void CJabberProto::UpdateMirVer(JABBER_LIST_ITEM *item) if ((resource < 0) || (resource >= item->resourceCount))
return;
- UpdateMirVer( hContact, &item->resource[resource] );
+ UpdateMirVer(hContact, &item->resource[resource]);
}
void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, int bufSize)
{
- if ( !buf || !bufSize ) return;
+ if ( !buf || !bufSize) return;
buf[ 0 ] = _T('\0');
- if ( !resource ) return;
+ if ( !resource) return;
// jabber:iq:version info requested and exists?
- if ( resource->dwVersionRequestTime && resource->software ) {
+ if (resource->dwVersionRequestTime && resource->software) {
Log("JabberUpdateMirVer: for iq:version rc " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM, resource->resourceName, resource->software);
if ( !resource->version || _tcsstr(resource->software, resource->version))
lstrcpyn(buf, resource->software, bufSize);
@@ -491,9 +491,9 @@ void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, in mir_sntprintf(buf, bufSize, _T("%s %s"), resource->software, resource->version);
}
// no version info and no caps info? set MirVer = resource name
- else if ( !resource->szCapsNode || !resource->szCapsVer ) {
+ else if ( !resource->szCapsNode || !resource->szCapsVer) {
Log("JabberUpdateMirVer: for rc " TCHAR_STR_PARAM ": " TCHAR_STR_PARAM, resource->resourceName, resource->resourceName);
- if ( resource->resourceName )
+ if (resource->resourceName)
lstrcpyn(buf, resource->resourceName, bufSize);
}
// XEP-0115 caps mode
@@ -504,21 +504,21 @@ void CJabberProto::FormatMirVer(JABBER_RESOURCE_STATUS *resource, TCHAR *buf, in // search through known software list
for (i = 0; i < SIZEOF(sttCapsNodeToName_Map); ++i)
- if ( _tcsstr( resource->szCapsNode, sttCapsNodeToName_Map[i].node ))
+ if (_tcsstr(resource->szCapsNode, sttCapsNodeToName_Map[i].node))
{
- mir_sntprintf( buf, bufSize, _T("%s %s"), sttCapsNodeToName_Map[i].name, resource->szCapsVer );
+ mir_sntprintf(buf, bufSize, _T("%s %s"), sttCapsNodeToName_Map[i].name, resource->szCapsVer);
break;
}
// unknown software
if (i == SIZEOF(sttCapsNodeToName_Map))
- mir_sntprintf( buf, bufSize, _T("%s %s"), resource->szCapsNode, resource->szCapsVer );
+ mir_sntprintf(buf, bufSize, _T("%s %s"), resource->szCapsNode, resource->szCapsVer);
}
// attach additional info for fingerprint plguin
if (resource->resourceName && !_tcsstr(buf, resource->resourceName))
{
- if (_tcsstr(buf, _T("Miranda IM")) || _tcsstr(buf, _T("Miranda NG")) || m_options.ShowForeignResourceInMirVer )
+ if (_tcsstr(buf, _T("Miranda IM")) || _tcsstr(buf, _T("Miranda NG")) || m_options.ShowForeignResourceInMirVer)
{
int offset = lstrlen(buf);
mir_sntprintf(buf + offset, bufSize - offset, _T(" [%s]"), resource->resourceName);
@@ -537,20 +537,20 @@ void CJabberProto::UpdateMirVer(HANDLE hContact, JABBER_RESOURCE_STATUS *resourc {
TCHAR szMirVer[ 512 ];
FormatMirVer(resource, szMirVer, SIZEOF(szMirVer));
- if ( szMirVer[0] )
- JSetStringT( hContact, "MirVer", szMirVer );
+ if (szMirVer[0])
+ JSetStringT(hContact, "MirVer", szMirVer);
// else
-// JDeleteSetting( hContact, "MirVer" );
+// JDeleteSetting(hContact, "MirVer");
DBVARIANT dbv;
- if ( !JGetStringT( hContact, "jid", &dbv )) {
+ if ( !JGetStringT(hContact, "jid", &dbv)) {
TCHAR szFullJid[ JABBER_MAX_JID_LEN ];
- if ( resource->resourceName )
- mir_sntprintf( szFullJid, SIZEOF( szFullJid ), _T("%s/%s"), dbv.ptszVal, resource->resourceName );
+ if (resource->resourceName)
+ mir_sntprintf(szFullJid, SIZEOF(szFullJid), _T("%s/%s"), dbv.ptszVal, resource->resourceName);
else
- lstrcpyn( szFullJid, dbv.ptszVal, SIZEOF(szFullJid));
- JSetStringT( hContact, DBSETTING_DISPLAY_UID, szFullJid );
- JFreeVariant( &dbv );
+ lstrcpyn(szFullJid, dbv.ptszVal, SIZEOF(szFullJid));
+ JSetStringT(hContact, DBSETTING_DISPLAY_UID, szFullJid);
+ db_free(&dbv);
}
}
@@ -585,18 +585,18 @@ void CJabberProto::UpdateSubscriptionInfo(HANDLE hContact, JABBER_LIST_ITEM *ite }
}
-void CJabberProto::SetContactOfflineStatus( HANDLE hContact )
+void CJabberProto::SetContactOfflineStatus(HANDLE hContact)
{
- if ( JGetWord( hContact, "Status", ID_STATUS_OFFLINE ) != ID_STATUS_OFFLINE )
- JSetWord( hContact, "Status", ID_STATUS_OFFLINE );
+ if (JGetWord(hContact, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE)
+ JSetWord(hContact, "Status", ID_STATUS_OFFLINE);
- JDeleteSetting( hContact, DBSETTING_XSTATUSID );
- JDeleteSetting( hContact, DBSETTING_XSTATUSNAME );
- JDeleteSetting( hContact, DBSETTING_XSTATUSMSG );
- JDeleteSetting( hContact, DBSETTING_DISPLAY_UID );
+ JDeleteSetting(hContact, DBSETTING_XSTATUSID);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSNAME);
+ JDeleteSetting(hContact, DBSETTING_XSTATUSMSG);
+ JDeleteSetting(hContact, DBSETTING_DISPLAY_UID);
- ResetAdvStatus( hContact, ADVSTATUS_MOOD );
- ResetAdvStatus( hContact, ADVSTATUS_TUNE );
+ ResetAdvStatus(hContact, ADVSTATUS_MOOD);
+ ResetAdvStatus(hContact, ADVSTATUS_TUNE);
//JabberUpdateContactExtraIcon(hContact);
}
|