void CJabberProto::SearchDeleteFromRecent( const TCHAR* szAddr, BOOL deleteLastFromDB ) { DBVARIANT dbv; char key[30]; //search in recent for ( int i=0; i<10; i++ ) { sprintf(key,"RecentlySearched_%d",i); if ( !JGetStringT( NULL, key, &dbv )) { if ( !_tcsicmp( szAddr, dbv.ptszVal )) { JFreeVariant( &dbv ); for ( int j=i; j<10; j++ ) { sprintf( key, "RecentlySearched_%d", j+1 ); if ( !JGetStringT( NULL, key, &dbv )) { sprintf(key,"RecentlySearched_%d",j); JSetStringT(NULL,key,dbv.ptszVal); JFreeVariant( &dbv ); } else { if ( deleteLastFromDB ) { sprintf(key,"RecentlySearched_%d",j); JDeleteSetting(NULL,key); } break; } } break; } else JFreeVariant( &dbv ); } } }
int JabberMenuBookmarkAdd( WPARAM wParam, LPARAM lParam ) { DBVARIANT dbv; if ( !wParam ) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) if ( !JGetStringT( ( HANDLE ) wParam, "ChatRoomID", &dbv )) { TCHAR *roomID = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); if ( JabberListGetItemPtr( LIST_BOOKMARK, roomID ) == NULL ) { TCHAR *nick = 0; if ( !JGetStringT( ( HANDLE ) wParam, "Nick", &dbv ) ) { nick = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); } JABBER_LIST_ITEM* item = NULL; item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM )); ZeroMemory( item, sizeof( JABBER_LIST_ITEM )); item->jid = mir_tstrdup(roomID); item->name = ( TCHAR* )JCallService( MS_CLIST_GETCONTACTDISPLAYNAME, wParam, GCDNF_TCHAR ); item->type = _T("conference"); if ( !JGetStringT(( HANDLE ) wParam, "MyNick", &dbv ) ) { item->nick = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); } JabberAddEditBookmark(NULL, (LPARAM) item); mir_free(item); if (nick) mir_free(nick); } mir_free(roomID); } return 0; }
INT_PTR __cdecl CJabberProto::OnJoinChat( WPARAM wParam, LPARAM ) { DBVARIANT nick, jid; HANDLE hContact = ( HANDLE )wParam; if ( JGetStringT( hContact, "ChatRoomID", &jid )) return 0; if ( JGetStringT( hContact, "MyNick", &nick )) if ( JGetStringT( NULL, "Nick", &nick )) { JFreeVariant( &jid ); return 0; } TCHAR *password = JGetStringCrypt( hContact, "LoginPassword" ); if ( JGetWord( hContact, "Status", 0 ) != ID_STATUS_ONLINE ) { if ( !jabberChatDllPresent ) JabberChatDllError(); else { TCHAR* p = _tcschr( jid.ptszVal, '@' ); if ( p != NULL ) { *p++ = 0; GroupchatJoinRoom( p, jid.ptszVal, nick.ptszVal, password ); } } } mir_free( password ); JFreeVariant( &nick ); JFreeVariant( &jid ); return 0; }
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 ); } }
int CJabberProto::OnContactDeleted( WPARAM wParam, LPARAM ) { if( !m_bJabberOnline ) // should never happen return 0; DBVARIANT dbv; if ( !JGetStringT(( HANDLE ) wParam, JGetByte( (HANDLE ) wParam, "ChatRoom", 0 )?(char*)"ChatRoomID":(char*)"jid", &dbv )) { if ( ListExist( LIST_ROSTER, dbv.ptszVal )) { if ( !_tcschr( dbv.ptszVal, _T( '@' ))) { TCHAR szStrippedJid[JABBER_MAX_JID_LEN]; JabberStripJid( m_ThreadInfo->fullJID, szStrippedJid, SIZEOF(szStrippedJid) ); TCHAR *szDog = _tcschr( szStrippedJid, _T('@')); if ( szDog && _tcsicmp( szDog + 1, dbv.ptszVal )) m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), dbv.ptszVal ) << XQUERY( _T(JABBER_FEAT_REGISTER)) << XCHILD( _T("remove"))); } // Remove from roster, server also handles the presence unsubscription process. m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext()) << XQUERY( _T(JABBER_FEAT_IQ_ROSTER)) << XCHILD( _T("item")) << XATTR( _T("jid"), dbv.ptszVal ) << XATTR( _T("subscription"), _T("remove"))); } JFreeVariant( &dbv ); } return 0; }
HWND __cdecl CJabberProto::CreateExtendedSearchUI( HWND parent ) { TCHAR szServer[128]; if (parent && hInst && (!JGetStringT(NULL, "LoginServer", szServer, SIZEOF(szServer)) || _tcsicmp(szServer, _T("S.ms")))) return CreateDialogParam( hInst, MAKEINTRESOURCE(IDD_SEARCHUSER), parent, JabberSearchAdvancedDlgProc, ( LPARAM )this ); return 0; // Failure }
int JabberMenuRosterAdd( WPARAM wParam, LPARAM lParam ) { DBVARIANT dbv; if ( !wParam ) return 0; // we do not add ourself to the roster. (buggy situation - should not happen) if ( !JGetStringT( ( HANDLE ) wParam, "ChatRoomID", &dbv )) { TCHAR *roomID = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); if ( JabberListGetItemPtr( LIST_ROSTER, roomID ) == NULL ) { TCHAR *nick = 0; TCHAR *group = 0; if ( !DBGetContactSettingTString( ( HANDLE ) wParam, "CList", "Group", &dbv ) ) { group = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); } if ( !JGetStringT( ( HANDLE ) wParam, "Nick", &dbv ) ) { nick = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); } JabberAddContactToRoster(roomID, nick, group, SUB_NONE); if ( JGetByte( "AddRoster2Bookmarks", TRUE ) == TRUE ) { JABBER_LIST_ITEM* item = NULL; item = JabberListGetItemPtr(LIST_BOOKMARK, roomID); if (!item) { item = ( JABBER_LIST_ITEM* )mir_alloc( sizeof( JABBER_LIST_ITEM )); ZeroMemory( item, sizeof( JABBER_LIST_ITEM )); item->jid = mir_tstrdup(roomID); item->name = mir_tstrdup(nick); if ( !JGetStringT( ( HANDLE ) wParam, "MyNick", &dbv ) ) { item->nick = mir_tstrdup(dbv.ptszVal); JFreeVariant( &dbv ); } JabberAddEditBookmark(NULL, (LPARAM) item); mir_free(item); } } if (nick) mir_free(nick); if (nick) mir_free(group); } mir_free(roomID); } return 0; }
TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName ) { DBVARIANT dbv = {0}; if (JGetStringT(hContact, valueName, &dbv)) return NULL; TCHAR *res = mir_tstrdup(dbv.ptszVal); JFreeVariant(&dbv); return res; }
TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName, TCHAR *buf, int size ) { DBVARIANT dbv = {0}; if (JGetStringT(hContact, valueName, &dbv)) return NULL; lstrcpyn(buf, dbv.ptszVal, size); JFreeVariant(&dbv); return buf; }
void JabberResolveTransportNicks( TCHAR* jid ) { // Set all contacts to offline HANDLE hContact = jabberThreadInfo->resolveContact; if ( hContact == NULL ) hContact = ( HANDLE ) JCallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); for ( ; hContact != NULL; hContact = ( HANDLE )JCallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM ) hContact, 0 )) { char* szProto = ( char* )JCallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 ); if ( lstrcmpA( szProto, jabberProtoName )) continue; if ( !JGetByte( hContact, "IsTransported", 0 )) continue; DBVARIANT dbv, nick; if ( JGetStringT( hContact, "jid", &dbv )) continue; if ( JGetStringT( hContact, "Nick", &nick )) { JFreeVariant( &dbv ); continue; } TCHAR* p = _tcschr( dbv.ptszVal, '@' ); if ( p ) { *p = 0; if ( !lstrcmp( jid, p+1 ) && !lstrcmp( dbv.ptszVal, nick.ptszVal )) { *p = '@'; jabberThreadInfo->resolveID = JabberSendGetVcard( dbv.ptszVal ); jabberThreadInfo->resolveContact = hContact; JFreeVariant( &dbv ); JFreeVariant( &nick ); return; } } JFreeVariant( &dbv ); JFreeVariant( &nick ); } jabberThreadInfo->resolveID = -1; jabberThreadInfo->resolveContact = NULL; }
HANDLE JabberDBCreateContact( TCHAR* jid, TCHAR* nick, BOOL temporary, BOOL stripResource ) { TCHAR* s, *p, *q; int len; char* szProto; if ( jid==NULL || jid[0]=='\0' ) return NULL; s = mir_tstrdup( jid ); q = NULL; // 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 = '/'; len = _tcslen( s ); // We can't use JabberHContactFromJID() here because of the stripResource option HANDLE hContact = ( HANDLE ) JCallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { szProto = ( char* )JCallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 ); if ( szProto!=NULL && !strcmp( jabberProtoName, szProto )) { DBVARIANT dbv; if ( !JGetStringT( hContact, "jid", &dbv )) { p = dbv.ptszVal; if ( p && ( int )_tcslen( p )>=len && ( p[len]=='\0'||p[len]=='/' ) && !_tcsnicmp( p, s, len )) { JFreeVariant( &dbv ); break; } JFreeVariant( &dbv ); } } hContact = ( HANDLE ) JCallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM ) hContact, 0 ); } if ( hContact == NULL ) { hContact = ( HANDLE ) JCallService( MS_DB_CONTACT_ADD, 0, 0 ); JCallService( MS_PROTO_ADDTOCONTACT, ( WPARAM ) hContact, ( LPARAM )jabberProtoName ); JSetStringT( hContact, "jid", s ); if ( nick != NULL && *nick != '\0' ) JSetStringT( hContact, "Nick", nick ); if ( temporary ) DBWriteContactSettingByte( hContact, "CList", "NotOnList", 1 ); else JabberSendGetVcard( s ); JabberLog( "Create Jabber contact jid=" TCHAR_STR_PARAM ", nick=" TCHAR_STR_PARAM, s, nick ); JabberDBCheckIsTransportedContact(s,hContact); } mir_free( s ); return hContact; }
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 ); }
int JabberMenuConvertChatContact( WPARAM wParam, LPARAM lParam ) { BYTE bIsChatRoom = (BYTE)JGetByte( (HANDLE ) wParam, "ChatRoom", 0 ); if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0 ) { DBVARIANT dbv; if ( !JGetStringT( (HANDLE ) wParam, (bIsChatRoom == GCW_CHATROOM)?(char*)"ChatRoomID":(char*)"jid", &dbv )) { JDeleteSetting( (HANDLE ) wParam, (bIsChatRoom == GCW_CHATROOM)?"ChatRoomID":"jid"); JSetStringT( (HANDLE ) wParam, (bIsChatRoom != GCW_CHATROOM)?"ChatRoomID":"jid", dbv.ptszVal); JFreeVariant( &dbv ); JSetByte((HANDLE ) wParam, "ChatRoom", (bIsChatRoom == GCW_CHATROOM)?0:GCW_CHATROOM); } } return 0; }
int JabberMenuTransportResolve( WPARAM wParam, LPARAM lParam ) { HANDLE hContact = ( HANDLE )wParam; if ( !JGetByte( hContact, "IsTransport", 0 )) return 0; DBVARIANT jid; if ( !JGetStringT( hContact, "jid", &jid )) { JabberResolveTransportNicks( jid.ptszVal ); JFreeVariant( &jid ); } return 0; }
INT_PTR __cdecl CJabberProto::OnMenuSendNote(WPARAM wParam, LPARAM) { if (!wParam) return 0; TCHAR szClientJid[ JABBER_MAX_JID_LEN ]; GetClientJID( JGetStringT( (HANDLE)wParam, "jid"), szClientJid, SIZEOF( szClientJid )); CNoteItem *pItem = new CNoteItem( NULL, szClientJid ); CJabberDlgBase *pDlg = new CJabberDlgNoteItem(this, pItem, &CJabberProto::ProcessOutgoingNote); pDlg->Show(); return 0; }
int JabberMenuRevokeAuth( WPARAM wParam, LPARAM lParam ) { HANDLE hContact; DBVARIANT dbv; if (( hContact=( HANDLE ) wParam )!=NULL && jabberOnline ) { if ( !JGetStringT( hContact, "jid", &dbv )) { XmlNode presence( "presence" ); presence.addAttr( "to", dbv.ptszVal ); presence.addAttr( "type", "unsubscribed" ); JabberSend( jabberThreadInfo->s, presence ); JFreeVariant( &dbv ); } } return 0; }
void JabberCheckAllContactsAreTransported() { HANDLE hContact = ( HANDLE ) JCallService( MS_DB_CONTACT_FINDFIRST, 0, 0 ); while ( hContact != NULL ) { char* szProto = ( char* )JCallService( MS_PROTO_GETCONTACTBASEPROTO, ( WPARAM ) hContact, 0 ); if ( !lstrcmpA( jabberProtoName, szProto )) { DBVARIANT dbv; if ( !JGetStringT( hContact, "jid", &dbv )) { JabberDBCheckIsTransportedContact( dbv.ptszVal, hContact ); JFreeVariant( &dbv ); } } hContact = ( HANDLE )JCallService( MS_DB_CONTACT_FINDNEXT, ( WPARAM )hContact, 0 ); } }
int JabberMenuJoinLeave( WPARAM wParam, LPARAM lParam ) { DBVARIANT dbv, jid; if ( JGetStringT(( HANDLE )wParam, "ChatRoomID", &jid )) return 0; if ( JGetStringT(( HANDLE )wParam, "MyNick", &dbv )) if ( JGetStringT( NULL, "Nick", &dbv )) { JFreeVariant( &jid ); return 0; } if ( JGetWord(( HANDLE )wParam, "Status", 0 ) != ID_STATUS_ONLINE ) { if ( !jabberChatDllPresent ) { JabberChatDllError(); goto LBL_Return; } TCHAR* p = _tcschr( jid.ptszVal, '@' ); if ( p == NULL ) goto LBL_Return; *p++ = 0; JabberGroupchatJoinRoom( p, jid.ptszVal, dbv.ptszVal, _T("")); } else { JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_CHATROOM, jid.ptszVal ); if ( item != NULL ) JabberGcQuit( item, 0, NULL ); } LBL_Return: JFreeVariant( &dbv ); JFreeVariant( &jid ); return 0; }
INT_PTR __cdecl CJabberProto::OnLeaveChat( WPARAM wParam, LPARAM ) { DBVARIANT jid; HANDLE hContact = ( HANDLE )wParam; if ( JGetStringT( hContact, "ChatRoomID", &jid )) return 0; if ( JGetWord( hContact, "Status", 0 ) != ID_STATUS_OFFLINE ) { JABBER_LIST_ITEM* item = ListGetItemPtr( LIST_CHATROOM, jid.ptszVal ); if ( item != NULL ) GcQuit( item, 0, NULL ); } JFreeVariant( &jid ); return 0; }
void CJabberProto::SearchAddToRecent( const TCHAR* szAddr, HWND hwndDialog ) { DBVARIANT dbv; char key[30]; SearchDeleteFromRecent( szAddr ); for ( int j=9; j > 0; j-- ) { sprintf( key, "RecentlySearched_%d", j-1 ); if ( !JGetStringT( NULL, key, &dbv )) { sprintf(key,"RecentlySearched_%d",j); JSetStringT(NULL,key,dbv.ptszVal); JFreeVariant(&dbv); } } sprintf( key, "RecentlySearched_%d", 0 ); JSetStringT( NULL, key, szAddr ); if ( hwndDialog ) JabberSearchAddUrlToRecentCombo( hwndDialog, szAddr ); }
int JabberMenuTransportLogin( WPARAM wParam, LPARAM lParam ) { HANDLE hContact = ( HANDLE )wParam; if ( !JGetByte( hContact, "IsTransport", 0 )) return 0; DBVARIANT jid; if ( JGetStringT( hContact, "jid", &jid )) return 0; JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_ROSTER, jid.ptszVal ); if ( item != NULL ) { XmlNode p( "presence" ); p.addAttr( "to", item->jid ); if ( item->status == ID_STATUS_ONLINE ) p.addAttr( "type", "unavailable" ); JabberSend( jabberThreadInfo->s, p ); } JFreeVariant( &jid ); return 0; }
TCHAR *CJabberProto::JGetStringT( HANDLE hContact, char* valueName, TCHAR *&out ) { return out = JGetStringT( hContact, valueName ); }
static BOOL CALLBACK JabberGroupchatDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { HWND lv; LVCOLUMN lvCol; LVITEM lvItem; JABBER_LIST_ITEM *item; switch ( msg ) { case WM_INITDIALOG: // lParam is the initial conference server ( if any ) SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )iconBigList[0] ); TranslateDialogDefault( hwndDlg ); sortColumn = -1; // Add columns lv = GetDlgItem( hwndDlg, IDC_ROOM ); lvCol.mask = LVCF_TEXT | LVCF_WIDTH | LVCF_SUBITEM; lvCol.pszText = TranslateT( "JID" ); lvCol.cx = 210; lvCol.iSubItem = 0; ListView_InsertColumn( lv, 0, &lvCol ); lvCol.pszText = TranslateT( "Name" ); lvCol.cx = 150; lvCol.iSubItem = 1; ListView_InsertColumn( lv, 1, &lvCol ); lvCol.pszText = TranslateT( "Type" ); lvCol.cx = 60; lvCol.iSubItem = 2; ListView_InsertColumn( lv, 2, &lvCol ); if ( jabberOnline ) { if (( TCHAR* )lParam != NULL ) { SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); int iqId = JabberSerialNext(); JabberIqAdd( iqId, IQ_PROC_DISCOROOMSERVER, JabberIqResultDiscoRoomItems ); XmlNodeIq iq( "get", iqId, ( TCHAR* )lParam ); XmlNode* query = iq.addQuery( "http://jabber.org/protocol/disco#items" ); JabberSend( jabberThreadInfo->s, iq ); } else { for ( int i=0; i < GC_SERVER_LIST_SIZE; i++ ) { char text[100]; mir_snprintf( text, sizeof( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )dbv.ptszVal ); JFreeVariant( &dbv ); } } } } else EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), FALSE ); return TRUE; case WM_JABBER_ACTIVATE: // lParam = server from which agent information is obtained if ( lParam ) SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_ROOM )); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); return TRUE; case WM_JABBER_REFRESH: // lParam = server from which agent information is obtained { int i; TCHAR szBuffer[256]; char text[128]; if ( lParam ){ _tcsncpy( szBuffer, ( TCHAR* )lParam, SIZEOF( szBuffer )); for ( i=0; i<GC_SERVER_LIST_SIZE; i++ ) { mir_snprintf( text, SIZEOF( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { JSetStringT( NULL, text, szBuffer ); if ( !_tcsicmp( dbv.ptszVal, ( TCHAR* )lParam )) { JFreeVariant( &dbv ); break; } _tcsncpy( szBuffer, dbv.ptszVal, SIZEOF( szBuffer )); JFreeVariant( &dbv ); } else { JSetStringT( NULL, text, szBuffer ); break; } } SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_RESETCONTENT, 0, 0 ); for ( i=0; i<GC_SERVER_LIST_SIZE; i++ ) { mir_snprintf( text, SIZEOF( text ), "GcServerLast%d", i ); DBVARIANT dbv; if ( !JGetStringT( NULL, text, &dbv )) { SendDlgItemMessage( hwndDlg, IDC_SERVER, CB_ADDSTRING, 0, ( LPARAM )dbv.ptszVal ); JFreeVariant( &dbv ); } } SetDlgItemText( hwndDlg, IDC_SERVER, ( TCHAR* )lParam ); } i = 0; lv = GetDlgItem( hwndDlg, IDC_ROOM ); ListView_DeleteAllItems( lv ); LVITEM lvItem; lvItem.iItem = 0; while (( i=JabberListFindNext( LIST_ROOM, i )) >= 0 ) { if (( item=JabberListGetItemPtrFromIndex( i )) != NULL ) { lvItem.mask = LVIF_PARAM | LVIF_TEXT; lvItem.iSubItem = 0; _tcsncpy( szBuffer, item->jid, SIZEOF(szBuffer)); szBuffer[ SIZEOF(szBuffer)-1 ] = 0; lvItem.lParam = ( LPARAM )item->jid; lvItem.pszText = szBuffer; ListView_InsertItem( lv, &lvItem ); lvItem.mask = LVIF_TEXT; lvItem.iSubItem = 1; lvItem.pszText = item->name; ListView_SetItem( lv, &lvItem ); lvItem.iSubItem = 2; lvItem.pszText = item->type; ListView_SetItem( lv, &lvItem ); lvItem.iItem++; } i++; } EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), TRUE ); } return TRUE; case WM_JABBER_CHECK_ONLINE: { TCHAR text[128]; if ( jabberOnline ) { EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), TRUE ); GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), ( text[0]!='\0' )); } else { EnableWindow( GetDlgItem( hwndDlg, IDC_JOIN ), FALSE ); EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); SetDlgItemTextA( hwndDlg, IDC_SERVER, "" ); lv = GetDlgItem( hwndDlg, IDC_ROOM ); ListView_DeleteAllItems( lv ); } break; } case WM_NOTIFY: switch ( wParam ) { case IDC_ROOM: switch (( ( LPNMHDR )lParam )->code ) { case LVN_COLUMNCLICK: { LPNMLISTVIEW pnmlv = ( LPNMLISTVIEW ) lParam; if ( pnmlv->iSubItem>=0 && pnmlv->iSubItem<=1 ) { if ( pnmlv->iSubItem == sortColumn ) sortAscending = !sortAscending; else { sortAscending = TRUE; sortColumn = pnmlv->iSubItem; } ListView_SortItems( GetDlgItem( hwndDlg, IDC_ROOM ), GroupchatCompare, sortColumn ); } } break; } break; } break; case WM_COMMAND: switch ( LOWORD( wParam )) { case WM_JABBER_JOIN: if ( jabberChatDllPresent ) { lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); ListView_SetItemState( lv, lvItem.iItem, 0, LVIS_SELECTED ); // Unselect the item DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_GROUPCHAT_JOIN ), hwndDlg, JabberGroupchatJoinDlgProc, ( LPARAM )lvItem.lParam ); } else { TCHAR text[128]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); DialogBoxParam( hInst, MAKEINTRESOURCE( IDD_GROUPCHAT_JOIN ), hwndDlg, JabberGroupchatJoinDlgProc, ( LPARAM )text ); } } else JabberChatDllError(); return TRUE; case WM_JABBER_ADD_TO_ROSTER: lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); TCHAR* jid = ( TCHAR* )lvItem.lParam; { GCSESSION gcw = {0}; gcw.cbSize = sizeof(GCSESSION); gcw.iType = GCW_CHATROOM; gcw.pszID = t2a(jid); gcw.pszModule = jabberProtoName; gcw.pszName = NEWSTR_ALLOCA(gcw.pszID); char* p = ( char* )strchr( gcw.pszName, '@' ); if ( p != NULL ) *p = 0; CallService( MS_GC_NEWSESSION, 0, ( LPARAM )&gcw ); mir_free((void*)gcw.pszID); } { XmlNodeIq iq( "set" ); XmlNode* query = iq.addQuery( "jabber:iq:roster" ); XmlNode* item = query->addChild( "item" ); item->addAttr( "jid", jid ); JabberSend( jabberThreadInfo->s, iq ); } { XmlNode p( "presence" ); p.addAttr( "to", jid ); p.addAttr( "type", "subscribe" ); JabberSend( jabberThreadInfo->s, p ); } } break; case WM_JABBER_ADD_TO_BOOKMARKS: lv = GetDlgItem( hwndDlg, IDC_ROOM ); if (( lvItem.iItem=ListView_GetNextItem( lv, -1, LVNI_SELECTED )) >= 0 ) { lvItem.iSubItem = 0; lvItem.mask = LVIF_PARAM; ListView_GetItem( lv, &lvItem ); JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_BOOKMARK, ( TCHAR* )lvItem.lParam ); if ( item == NULL ) { item = JabberListGetItemPtr( LIST_ROOM, ( TCHAR* )lvItem.lParam ); if (item != NULL) { item->type = _T("conference"); JabberAddEditBookmark(NULL, (LPARAM) item); } } } break; case IDC_SERVER: { TCHAR text[ 128 ]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); if ( jabberOnline && ( text[0] || HIWORD( wParam )==CBN_SELCHANGE )) EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), TRUE ); break; } case IDC_BROWSE: { TCHAR text[ 128 ]; GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); if ( jabberOnline && text[0] ) { EnableWindow( GetDlgItem( hwndDlg, IDC_BROWSE ), FALSE ); ListView_DeleteAllItems( GetDlgItem( hwndDlg, IDC_ROOM )); GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); int iqId = JabberSerialNext(); JabberIqAdd( iqId, IQ_PROC_DISCOROOMSERVER, JabberIqResultDiscoRoomItems ); XmlNodeIq iq( "get", iqId, text ); XmlNode* query = iq.addQuery( "http://jabber.org/protocol/disco#items" ); JabberSend( jabberThreadInfo->s, iq ); } return TRUE; } case IDCLOSE: DestroyWindow( hwndDlg ); return TRUE; } break; case WM_CONTEXTMENU: if (( HWND )wParam == GetDlgItem( hwndDlg, IDC_ROOM )) { HMENU hMenu = CreatePopupMenu(); AppendMenu( hMenu, MF_STRING, WM_JABBER_JOIN, TranslateT( "Join" )); AppendMenu( hMenu, MF_STRING, WM_JABBER_ADD_TO_ROSTER, TranslateT( "Add to roster" )); if ( jabberThreadInfo->caps & CAPS_BOOKMARK ) AppendMenu( hMenu, MF_STRING, WM_JABBER_ADD_TO_BOOKMARKS, TranslateT( "Add to Bookmarks" )); TrackPopupMenu( hMenu, TPM_LEFTALIGN | TPM_NONOTIFY, LOWORD(lParam), HIWORD(lParam), 0, hwndDlg, 0 ); ::DestroyMenu( hMenu ); return TRUE; } break; case WM_CLOSE: DestroyWindow( hwndDlg ); break; case WM_DESTROY: hwndJabberGroupchat = NULL; break; } return FALSE; }
static BOOL CALLBACK JabberGroupchatJoinDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { TCHAR text[128]; TCHAR* p; switch ( msg ) { case WM_INITDIALOG: { // lParam is the room JID ( room@server ) in UTF-8 hwndJabberJoinGroupchat = hwndDlg; TranslateDialogDefault( hwndDlg ); if ( lParam ){ _tcsncpy( text, ( TCHAR* )lParam, SIZEOF( text )); if (( p = _tcschr( text, '@' )) != NULL ) { *p = '\0'; // Need to save room name in UTF-8 in case the room codepage is different // from the local code page TCHAR* room = mir_tstrdup( text ); SetWindowLong( hwndDlg, GWL_USERDATA, ( LONG ) room ); SetDlgItemText( hwndDlg, IDC_ROOM, room ); SetDlgItemText( hwndDlg, IDC_SERVER, p+1 ); } else SetDlgItemText( hwndDlg, IDC_SERVER, text ); } DBVARIANT dbv; if ( !JGetStringT( NULL, "Nick", &dbv )) { SetDlgItemText( hwndDlg, IDC_NICK, dbv.ptszVal ); JFreeVariant( &dbv ); } else { TCHAR* nick = JabberNickFromJID( jabberJID ); SetDlgItemText( hwndDlg, IDC_NICK, nick ); mir_free( nick ); } } return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_ROOM: if (( HWND )lParam==GetFocus() && HIWORD( wParam )==EN_CHANGE ) { // Change in IDC_ROOM field is detected, // invalidate the saved UTF-8 room name if any char* str = ( char* )GetWindowLong( hwndDlg, GWL_USERDATA ); if ( str != NULL ) { mir_free( str ); SetWindowLong( hwndDlg, GWL_USERDATA, ( LONG ) NULL ); } } break; case IDOK: { GetDlgItemText( hwndDlg, IDC_SERVER, text, SIZEOF( text )); TCHAR* server = NEWTSTR_ALLOCA( text ), *room; if (( room=( TCHAR* )GetWindowLong( hwndDlg, GWL_USERDATA )) != NULL ) room = NEWTSTR_ALLOCA( room ); else { GetDlgItemText( hwndDlg, IDC_ROOM, text, SIZEOF( text )); room = NEWTSTR_ALLOCA( text ); } GetDlgItemText( hwndDlg, IDC_NICK, text, SIZEOF( text )); TCHAR* nick = NEWTSTR_ALLOCA( text ); GetDlgItemText( hwndDlg, IDC_PASSWORD, text, SIZEOF( text )); TCHAR* password = NEWTSTR_ALLOCA( text ); JabberGroupchatJoinRoom( server, room, nick, password ); } // fall through case IDCANCEL: EndDialog( hwndDlg, 0 ); break; } break; case WM_JABBER_CHECK_ONLINE: if ( !jabberOnline ) EndDialog( hwndDlg, 0 ); break; case WM_DESTROY: { char* str = ( char* )GetWindowLong( hwndDlg, GWL_USERDATA ); if ( str != NULL ) mir_free( str ); hwndJabberJoinGroupchat = NULL; } break; } return FALSE; }
int JabberMenuProcessSrmmIconClick( WPARAM wParam, LPARAM lParam ) { StatusIconClickData *sicd = (StatusIconClickData *)lParam; if (lstrcmpA(sicd->szModule, jabberProtoName)) return 0; HANDLE hContact = (HANDLE)wParam; if (!hContact) return 0; DBVARIANT dbv; if (JGetStringT(hContact, "jid", &dbv)) return 0; JABBER_LIST_ITEM *LI = JabberListGetItemPtr(LIST_ROSTER, dbv.ptszVal); JFreeVariant( &dbv ); if (!LI) return 0; HMENU hMenu = CreatePopupMenu(); TCHAR buf[256]; mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), TranslateT("Last active"), ((LI->lastSeenResource>=0) && (LI->lastSeenResource < LI->resourceCount)) ? LI->resource[LI->lastSeenResource].resourceName : TranslateT("No activity yet, use server's choice")); AppendMenu(hMenu, MF_STRING, MENUITEM_LASTSEEN, buf); AppendMenu(hMenu, MF_STRING, MENUITEM_SERVER, TranslateT("Highest priority (server's choice)")); AppendMenu(hMenu, MF_SEPARATOR, 0, NULL); for (int i = 0; i < LI->resourceCount; ++i) AppendMenu(hMenu, MF_STRING, MENUITEM_RESOURCES+i, LI->resource[i].resourceName); if (LI->resourceMode == RSMODE_LASTSEEN) CheckMenuItem(hMenu, MENUITEM_LASTSEEN, MF_BYCOMMAND|MF_CHECKED); else if (LI->resourceMode == RSMODE_SERVER) CheckMenuItem(hMenu, MENUITEM_SERVER, MF_BYCOMMAND|MF_CHECKED); else CheckMenuItem(hMenu, MENUITEM_RESOURCES+LI->manualResource, MF_BYCOMMAND|MF_CHECKED); int res = TrackPopupMenu(hMenu, TPM_RETURNCMD, sicd->clickLocation.x, sicd->clickLocation.y, 0, WindowList_Find(hDialogsList, hContact), NULL); if (res == MENUITEM_LASTSEEN) { LI->manualResource = -1; LI->resourceMode = RSMODE_LASTSEEN; } else if (res == MENUITEM_SERVER) { LI->manualResource = -1; LI->resourceMode = RSMODE_SERVER; } else if (res >= MENUITEM_RESOURCES) { LI->manualResource = res - MENUITEM_RESOURCES; LI->resourceMode = RSMODE_MANUAL; } JabberUpdateMirVer(LI); JabberMenuUpdateSrmmIcon(LI); return 0; }
int JabberMenuPrebuildContactMenu( WPARAM wParam, LPARAM lParam ) { sttEnableMenuItem( hMenuRequestAuth, FALSE ); sttEnableMenuItem( hMenuGrantAuth, FALSE ); sttEnableMenuItem( hMenuRevokeAuth, FALSE ); sttEnableMenuItem( hMenuJoinLeave, FALSE ); sttEnableMenuItem( hMenuCommands, FALSE ); sttEnableMenuItem( hMenuConvert, FALSE ); sttEnableMenuItem( hMenuRosterAdd, FALSE ); sttEnableMenuItem( hMenuLogin, FALSE ); sttEnableMenuItem( hMenuVisitGMail, FALSE ); sttEnableMenuItem( hMenuRefresh, FALSE ); sttEnableMenuItem( hMenuAddBookmark, FALSE ); HANDLE hContact; if (( hContact=( HANDLE )wParam ) == NULL ) return 0; else { DBVARIANT dbv; if ( !JGetStringT( hContact, "FakeContact", &dbv )) { if (!_tcsicmp( dbv.ptszVal, _T("GMAIL"))){ sttEnableMenuItem( hMenuVisitGMail, TRUE ); return 0; } JFreeVariant( &dbv ); } } BYTE bIsChatRoom = (BYTE)JGetByte( hContact, "ChatRoom", 0 ); BYTE bIsTransport = (BYTE)JGetByte( hContact, "IsTransport", 0 ); if ((bIsChatRoom == GCW_CHATROOM) || bIsChatRoom == 0 ) { DBVARIANT dbv; if ( !JGetStringT( hContact, bIsChatRoom?(char*)"ChatRoomID":(char*)"jid", &dbv )) { JFreeVariant( &dbv ); CLISTMENUITEM clmi = { 0 }; sttEnableMenuItem( hMenuConvert, TRUE ); clmi.cbSize = sizeof( clmi ); clmi.pszName = (char *)(bIsChatRoom ? "&Convert to Contact" : "&Convert to Chat Room"); clmi.flags = CMIM_NAME | CMIM_FLAGS; JCallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hMenuConvert, ( LPARAM )&clmi ); } } if (!jabberOnline) return 0; if ( bIsChatRoom ) { DBVARIANT dbv; if ( !JGetStringT( hContact, "ChatRoomID", &dbv )) { if ( JabberListGetItemPtr( LIST_ROSTER, dbv.ptszVal ) == NULL ) sttEnableMenuItem( hMenuRosterAdd, TRUE ); if ( JabberListGetItemPtr( LIST_BOOKMARK, dbv.ptszVal ) == NULL ) if ( jabberThreadInfo && jabberThreadInfo->caps & CAPS_BOOKMARK ) sttEnableMenuItem( hMenuAddBookmark, TRUE ); JFreeVariant( &dbv ); } } if ( bIsChatRoom == GCW_CHATROOM ) { CLISTMENUITEM clmi = { 0 }; clmi.cbSize = sizeof( clmi ); clmi.pszName = (char *)(( JGetWord( hContact, "Status", 0 ) == ID_STATUS_ONLINE ) ? "&Leave" : "&Join"); clmi.flags = CMIM_NAME | CMIM_FLAGS; JCallService( MS_CLIST_MODIFYMENUITEM, ( WPARAM )hMenuJoinLeave, ( LPARAM )&clmi ); return 0; } if ( bIsTransport ) { sttEnableMenuItem( hMenuLogin, TRUE ); sttEnableMenuItem( hMenuRefresh, TRUE ); } DBVARIANT dbv; if ( !JGetStringT( hContact, "jid", &dbv )) { JABBER_LIST_ITEM * item; item=JabberListGetItemPtr( LIST_ROSTER, dbv.ptszVal ); if ( !bIsTransport || (( item != NULL ) && (item->cap & AGENT_CAP_ADHOC) ) ) { sttEnableMenuItem( hMenuCommands, TRUE ); } else sttEnableMenuItem( hMenuCommands, FALSE ); JFreeVariant( &dbv ); } if ( !JGetStringT( hContact, "jid", &dbv )) { JABBER_LIST_ITEM* item = JabberListGetItemPtr( LIST_ROSTER, dbv.ptszVal ); JFreeVariant( &dbv ); if ( item != NULL ) { BOOL bCtrlPressed = ( GetKeyState( VK_CONTROL)&0x8000 ) != 0; sttEnableMenuItem( hMenuRequestAuth, item->subscription == SUB_FROM || item->subscription == SUB_NONE || bCtrlPressed ); sttEnableMenuItem( hMenuGrantAuth, item->subscription == SUB_TO || item->subscription == SUB_NONE || bCtrlPressed ); sttEnableMenuItem( hMenuRevokeAuth, item->subscription == SUB_FROM || item->subscription == SUB_BOTH || bCtrlPressed ); sttEnableMenuItem( hMenuCommands, (!bIsChatRoom && (!bIsTransport || (item->cap & AGENT_CAP_ADHOC))) ); return 0; } } return 0; }
static BOOL CALLBACK JabberGcLogInviteDlgProc( HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam ) { switch ( msg ) { case WM_INITDIALOG: { RECT dlgRect, scrRect; GetWindowRect( hwndDlg, &dlgRect ); SystemParametersInfo( SPI_GETWORKAREA, 0, &scrRect, 0 ); SetWindowPos( hwndDlg, HWND_TOPMOST, (scrRect.right/2)-(dlgRect.right/2), (scrRect.bottom/2)-(dlgRect.bottom/2), 0, 0, SWP_NOSIZE ); TranslateDialogDefault( hwndDlg ); SendMessage( hwndDlg, WM_SETICON, ICON_BIG, ( LPARAM )iconBigList[0]); SetDlgItemText( hwndDlg, IDC_ROOM, ( TCHAR* )lParam ); SetWindowLong(GetDlgItem(hwndDlg, IDC_CLIST), GWL_STYLE, GetWindowLong(GetDlgItem(hwndDlg, IDC_CLIST), GWL_STYLE)|CLS_HIDEOFFLINE|CLS_CHECKBOXES|CLS_HIDEEMPTYGROUPS|CLS_USEGROUPS|CLS_GREYALTERNATE|CLS_GROUPCHECKBOXES); SendMessage(GetDlgItem(hwndDlg, IDC_CLIST), CLM_SETEXSTYLE, CLS_EX_DISABLEDRAGDROP|CLS_EX_TRACKSELECT, 0); ResetListOptions(GetDlgItem(hwndDlg, IDC_CLIST)); FilterList(GetDlgItem(hwndDlg, IDC_CLIST)); SendDlgItemMessage(hwndDlg, IDC_ADDJID, BUTTONSETASFLATBTN, 0, 0); SendDlgItemMessage(hwndDlg, IDC_ADDJID, BM_SETIMAGE, IMAGE_ICON, (LPARAM)iconList[17]);//LoadIconEx("addroster")); // use new operator to properly construct LIST object JabberGcLogInviteDlgData *data = new JabberGcLogInviteDlgData((TCHAR *)lParam); data->room = mir_tstrdup((TCHAR *)lParam); SetWindowLong(hwndDlg, GWL_USERDATA, (LONG)data); } return TRUE; case WM_COMMAND: switch ( LOWORD( wParam )) { case IDC_ADDJID: { TCHAR buf[JABBER_MAX_JID_LEN]; GetWindowText(GetDlgItem(hwndDlg, IDC_NEWJID), buf, SIZEOF(buf)); SetWindowText(GetDlgItem(hwndDlg, IDC_NEWJID), _T("")); if (JabberHContactFromJID(buf)) break; JabberGcLogInviteDlgData *data = (JabberGcLogInviteDlgData *)GetWindowLong(hwndDlg, GWL_USERDATA); int i; for (i = 0; i < data->newJids.getCount(); ++i) if (!lstrcmp(data->newJids[i]->jid, buf)) break; if (i != data->newJids.getCount()) break; JabberGcLogInviteDlgJidData *jidData = (JabberGcLogInviteDlgJidData *)mir_alloc(sizeof(JabberGcLogInviteDlgJidData)); lstrcpy(jidData->jid, buf); CLCINFOITEM cii = {0}; cii.cbSize = sizeof(cii); cii.flags = CLCIIF_CHECKBOX; mir_sntprintf(buf, SIZEOF(buf), _T("%s (%s)"), jidData->jid, TranslateT("not on roster")); cii.pszText = buf; jidData->hItem = SendDlgItemMessage(hwndDlg,IDC_CLIST,CLM_ADDINFOITEM,0,(LPARAM)&cii); SendDlgItemMessage(hwndDlg, IDC_CLIST, CLM_SETCHECKMARK, jidData->hItem, 1); data->newJids.insert(jidData); } break; case IDC_INVITE: { JabberGcLogInviteDlgData *data = (JabberGcLogInviteDlgData *)GetWindowLong(hwndDlg, GWL_USERDATA); TCHAR* room = data->room; if ( room != NULL ) { TCHAR text[256]; GetDlgItemText( hwndDlg, IDC_REASON, text, SIZEOF( text )); HWND hwndList = GetDlgItem(hwndDlg, IDC_CLIST); // invite users from roster for (HANDLE hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDFIRST, 0, 0); hContact; hContact = (HANDLE)CallService(MS_DB_CONTACT_FINDNEXT, (WPARAM)hContact, 0)) { char *proto = (char *)CallService(MS_PROTO_GETCONTACTBASEPROTO, (WPARAM)hContact, 0); if ( !lstrcmpA(proto, jabberProtoName) && !DBGetContactSettingByte(hContact, proto, "ChatRoom", 0)) { if (int hItem = SendMessage(hwndList, CLM_FINDCONTACT, (WPARAM)hContact, 0)) { if ( SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)hItem, 0 )) { DBVARIANT dbv={0}; JGetStringT(hContact, "jid", &dbv); if (dbv.ptszVal && ( dbv.type == DBVT_ASCIIZ || dbv.type == DBVT_WCHAR )) InviteUser(room, dbv.ptszVal, text); JFreeVariant(&dbv); } } } } // invite others for (int i = 0; i < data->newJids.getCount(); ++i) if (SendMessage(hwndList, CLM_GETCHECKMARK, (WPARAM)data->newJids[i]->hItem, 0)) InviteUser(room, data->newJids[i]->jid, text); } } // Fall through case IDCANCEL: case IDCLOSE: DestroyWindow( hwndDlg ); return TRUE; } break; case WM_NOTIFY: if (((LPNMHDR)lParam)->idFrom == IDC_CLIST) { switch (((LPNMHDR)lParam)->code) { case CLN_NEWCONTACT: FilterList(GetDlgItem(hwndDlg,IDC_CLIST)); break; case CLN_LISTREBUILT: FilterList(GetDlgItem(hwndDlg,IDC_CLIST)); break; case CLN_OPTIONSCHANGED: ResetListOptions(GetDlgItem(hwndDlg,IDC_CLIST)); break; } } break; case WM_CLOSE: DestroyWindow( hwndDlg ); break; case WM_DESTROY: JabberGcLogInviteDlgData *data = (JabberGcLogInviteDlgData *)GetWindowLong(hwndDlg, GWL_USERDATA); delete data; break; } return FALSE; }
static BOOL CALLBACK JabberSearchAdvancedDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { JabberSearchData* dat = ( JabberSearchData* )GetWindowLong( hwndDlg, GWL_USERDATA ); switch ( msg ) { case WM_INITDIALOG: { TranslateDialogDefault(hwndDlg); dat=(JabberSearchData *)malloc(sizeof(JabberSearchData)); memset(dat,0,sizeof(JabberSearchData)); SetWindowLong(hwndDlg,GWL_USERDATA,(LPARAM)dat); /* Server Combo box */ char szServerName[100]; if ( JGetStaticString( "Jud", NULL, szServerName, sizeof szServerName )) strcpy( szServerName, "users.jabber.org" ); SetDlgItemTextA(hwndDlg,IDC_SERVER,szServerName); SendDlgItemMessageA(hwndDlg,IDC_SERVER,CB_ADDSTRING,0,(LPARAM)szServerName); //TO DO: Add Transports here int i, transpCount = jabberTransports.getCount(); for ( i=0; i < transpCount; i++ ) { TCHAR* szTransp = jabberTransports[i]; if ( szTransp ) JabberSearchAddUrlToRecentCombo(hwndDlg, szTransp ); } DBVARIANT dbv; char key[30]; for ( i=0; i < 10; i++ ) { sprintf(key,"RecentlySearched_%d",i); if (!JGetStringT( NULL, key, &dbv )) { JabberSearchAddUrlToRecentCombo(hwndDlg, dbv.ptszVal ); JFreeVariant( &dbv ); } } //TO DO: Add 4 recently used dat->lastRequestIq=JabbeSearchrRenewFields(hwndDlg,dat); } return TRUE; case WM_COMMAND: if ( LOWORD(wParam) == IDC_SERVER ) { switch ( HIWORD( wParam )) { case CBN_SETFOCUS: PostMessage(GetParent(hwndDlg),WM_COMMAND, MAKEWPARAM(0,EN_SETFOCUS), (LPARAM)hwndDlg); return TRUE; case CBN_EDITCHANGE: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_EDITUPDATE: JabberSearchFreeData(hwndDlg, dat); EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); return TRUE; case CBN_SELENDOK: EnableWindow(GetDlgItem(hwndDlg, IDC_GO),TRUE); PostMessage(hwndDlg,WM_COMMAND,MAKEWPARAM(IDC_GO,BN_CLICKED),0); return TRUE; } } else if ( LOWORD(wParam) == IDC_GO && HIWORD(wParam) == BN_CLICKED ) { JabbeSearchrRenewFields( hwndDlg, dat ); return TRUE; } break; case WM_SIZE: { //Resize IDC_FRAME to take full size RECT rcForm; GetWindowRect(hwndDlg, &rcForm); RECT rcFrame; GetWindowRect( GetDlgItem(hwndDlg, IDC_FRAME), &rcFrame ); rcFrame.bottom = rcForm.bottom; SetWindowPos(GetDlgItem(hwndDlg,IDC_FRAME),NULL,0,0,rcFrame.right-rcFrame.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); GetWindowRect(GetDlgItem(hwndDlg,IDC_VSCROLL), &rcForm); SetWindowPos(GetDlgItem(hwndDlg,IDC_VSCROLL),NULL,0,0,rcForm.right-rcForm.left,rcFrame.bottom-rcFrame.top,SWP_NOZORDER|SWP_NOMOVE); JabberSearchRefreshFrameScroll(hwndDlg, dat); } return TRUE; case WM_USER+11: { dat->fSearchRequestIsXForm=TRUE; dat->xNode=JabberXmlCopyNode( (XmlNode *) wParam ); JabberFormCreateUI(GetDlgItem(hwndDlg, IDC_FRAME), dat->xNode, &dat->CurrentHeight,TRUE); ShowWindow(GetDlgItem(hwndDlg, IDC_FRAME), SW_SHOW); dat->nJSInfCount=1; return TRUE; } case WM_USER+10: { Data* MyDat = ( Data* )lParam; if ( MyDat ) { dat->fSearchRequestIsXForm = ( BOOL )wParam; dat->CurrentHeight = JabberSearchAddField(hwndDlg,MyDat); mir_free( MyDat->Label ); mir_free( MyDat->Var ); mir_free( MyDat->defValue ); free( MyDat ); } else { JabberSearchRefreshFrameScroll(hwndDlg,dat); ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - 0, NULL, &( dat->frameRect )); SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, 0, FALSE ); dat->curPos=0; } return TRUE; } case WM_MOUSEWHEEL: { int zDelta = GET_WHEEL_DELTA_WPARAM(wParam); if ( zDelta ) { int nScrollLines=0; SystemParametersInfo(SPI_GETWHEELSCROLLLINES,0,(void*)&nScrollLines,0); for (int i=0; i<(nScrollLines+1)/2; i++) SendMessage(hwndDlg,WM_VSCROLL, (zDelta<0)?SB_LINEDOWN:SB_LINEUP,0); } } return TRUE; case WM_VSCROLL: { int pos; if ( dat != NULL ) { pos = dat->curPos; switch ( LOWORD( wParam )) { case SB_LINEDOWN: pos += 10; break; case SB_LINEUP: pos -= 10; break; case SB_PAGEDOWN: pos += ( dat->CurrentHeight - 10 ); break; case SB_PAGEUP: pos -= ( dat->CurrentHeight - 10 ); break; case SB_THUMBTRACK: pos = HIWORD( wParam ); break; } if ( pos > ( dat->CurrentHeight - dat->frameHeight )) pos = dat->CurrentHeight - dat->frameHeight; if ( pos < 0 ) pos = 0; if ( dat->curPos != pos ) { ScrollWindow( GetDlgItem( hwndDlg, IDC_FRAME ), 0, dat->curPos - pos, NULL , &( dat->frameRect )); SetScrollPos( GetDlgItem( hwndDlg, IDC_VSCROLL ), SB_CTL, pos, TRUE ); RECT Invalid=dat->frameRect; if (dat->curPos - pos >0) Invalid.bottom=Invalid.top+(dat->curPos - pos); else Invalid.top=Invalid.bottom+(dat->curPos - pos); RedrawWindow(GetDlgItem( hwndDlg, IDC_FRAME ), NULL, NULL, RDW_UPDATENOW |RDW_ALLCHILDREN); dat->curPos = pos; } } } return TRUE; case WM_DESTROY: JabberSearchFreeData(hwndDlg,dat); dat=NULL; return TRUE; } return FALSE; }