BOOL CJabberProto::OnMessageError(HXML node, ThreadData*, CJabberMessageInfo* pInfo) { // we check if is message delivery failure int id = JabberGetPacketID(node); JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_ROSTER, pInfo->GetFrom()); if (item == NULL) item = ListGetItemPtr(LIST_CHATROOM, pInfo->GetFrom()); if (item != NULL) { // yes, it is TCHAR *szErrText = JabberErrorMsg(pInfo->GetChildNode()); if (id != -1) { char *errText = mir_t2a(szErrText); ProtoBroadcastAck(pInfo->GetHContact(), ACKTYPE_MESSAGE, ACKRESULT_FAILED, (HANDLE)id, (LPARAM)errText); mir_free(errText); } else { TCHAR buf[512]; HXML bodyNode = xmlGetChild(node, "body"); if (bodyNode) mir_sntprintf(buf, SIZEOF(buf), _T("%s:\n%s\n%s"), pInfo->GetFrom(), xmlGetText(bodyNode), szErrText); else mir_sntprintf(buf, SIZEOF(buf), _T("%s:\n%s"), pInfo->GetFrom(), szErrText); MsgPopup(NULL, buf, TranslateT("Jabber Error")); } mir_free(szErrText); } return TRUE; }
void CJabberProto::IqResultStreamActivate( HXML iqNode ) { int id = JabberGetPacketID( iqNode ); TCHAR listJid[JABBER_MAX_JID_LEN]; mir_sntprintf(listJid, SIZEOF( listJid ), _T("ftproxy_%d"), id); JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_FTIQID, listJid ); if ( !item ) return; if ( !lstrcmp( xmlGetAttrValue( iqNode, _T("type")), _T( "result" ))) item->jbt->bStreamActivated = TRUE; if ( item->jbt->hProxyEvent ) SetEvent( item->jbt->hProxyEvent ); }
void CJabberProto::OnIqResultAdvancedSearch( HXML iqNode ) { const TCHAR* type; int id; U_TCHAR_MAP mColumnsNames(10); LIST<void> SearchResults(2); if ((( id = JabberGetPacketID( iqNode )) == -1 ) || (( type = xmlGetAttrValue( iqNode, _T("type"))) == NULL )) { JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); return; } if ( !lstrcmp( type, _T("result"))) { HXML queryNode = xmlGetNthChild( iqNode, _T("query"), 1 ); HXML xNode = xmlGetChildByTag( queryNode, "x", "xmlns", _T(JABBER_FEAT_DATA_FORMS)); if (xNode) { //1. Form search results info HXML reportNode = xmlGetNthChild( xNode, _T("reported"), 1 ); if (reportNode) { int i = 1; while ( HXML fieldNode = xmlGetNthChild( reportNode, _T("field"), i++ )) { TCHAR* var = ( TCHAR* )xmlGetAttrValue( fieldNode, _T( "var" )); if ( var ) { TCHAR* Label = ( TCHAR* )xmlGetAttrValue( fieldNode, _T( "label" )); mColumnsNames.insert(var, (Label!=NULL) ? Label : var); } } } int i=1; HXML itemNode; while ( itemNode = xmlGetNthChild( xNode, _T("item"), i++ )) { U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10); int j = 1; while ( HXML fieldNode = xmlGetNthChild( itemNode, _T("field"), j++ )) { if ( TCHAR* var = (TCHAR*)xmlGetAttrValue( fieldNode, _T("var"))) { if ( TCHAR* Text = (TCHAR*)xmlGetText( xmlGetChild( fieldNode, _T("value")))) { if ( !mColumnsNames[var] ) mColumnsNames.insert(var,var); pUserColumn->insert(var,Text); } } } SearchResults.insert((void*)pUserColumn); } } else { //2. Field list search results info int i=1; while ( HXML itemNode = xmlGetNthChild( queryNode, _T("item"), i++ )) { U_TCHAR_MAP *pUserColumn=new U_TCHAR_MAP(10); TCHAR* jid = (TCHAR*)xmlGetAttrValue( itemNode, _T("jid")); TCHAR* keyReturned; mColumnsNames.insertCopyKey( _T("jid"),_T("jid"),&keyReturned, CopyKey, DestroyKey ); mColumnsNames.insert( _T("jid"), keyReturned ); pUserColumn->insertCopyKey( _T("jid"), jid, NULL, CopyKey, DestroyKey ); for ( int j=0; ; j++ ) { HXML child = xmlGetChild( itemNode, j ); if ( !child ) break; const TCHAR* szColumnName = xmlGetName( child ); if ( szColumnName ) { if ( xmlGetText( child ) && xmlGetText( child )[0] != _T('\0')) { mColumnsNames.insertCopyKey(( TCHAR* )szColumnName,_T(""),&keyReturned, CopyKey, DestroyKey); mColumnsNames.insert(( TCHAR* )szColumnName,keyReturned); pUserColumn->insertCopyKey(( TCHAR* )szColumnName, ( TCHAR* )xmlGetText( child ),NULL, CopyKey, DestroyKey); } } } SearchResults.insert((void*)pUserColumn); } } } else if (!lstrcmp( type, _T("error"))) { const TCHAR* code=NULL; const TCHAR* description=NULL; TCHAR buff[255]; HXML errorNode = xmlGetChild( iqNode , "error" ); if (errorNode) { code = xmlGetAttrValue( errorNode, _T("code")); description = xmlGetText( errorNode ); } _sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nTry to specify more detailed"),code ? code : _T(""),description?description:_T("")); JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); if (searchHandleDlg ) SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff); else MessageBox(NULL, buff, TranslateT("Search error"), MB_OK|MB_ICONSTOP); return; } SearchReturnResults((HANDLE)id, (void*)&SearchResults, (U_TCHAR_MAP *)&mColumnsNames); for (int i=0; i < SearchResults.getCount(); i++ ) delete ((U_TCHAR_MAP *)SearchResults[i]); //send success to finish searching JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); }
static void JabberIqResultAdvancedSearch( XmlNode *iqNode, void *userdata ) { TCHAR* type; int id; U_TCHAR_MAP mColumnsNames(10); LIST<void> SearchResults(2); if ((( id = JabberGetPacketID( iqNode )) == -1 ) || (( type = JabberXmlGetAttrValue( iqNode, "type" )) == NULL )) { JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); return; } if ( !lstrcmp( type, _T("result"))) { XmlNode* queryNode=JabberXmlGetNthChild(iqNode,"query",1); XmlNode* xNode = JabberXmlGetChildWithGivenAttrValue( queryNode, "x", "xmlns", _T("jabber:x:data")); if (xNode) { //1. Form search results info XmlNode* reportNode=JabberXmlGetNthChild(xNode,"reported",1); if (reportNode) { int i = 1; while ( XmlNode* fieldNode = JabberXmlGetNthChild( reportNode, "field", i++ )) { TCHAR* var = JabberXmlGetAttrValue( fieldNode, "var" ); if ( var ) { TCHAR * Label=JabberXmlGetAttrValue(fieldNode,"label"); mColumnsNames.insert(var, (Label!=NULL) ? Label : var); } } } int i=1; XmlNode* itemNode; while ( itemNode = JabberXmlGetNthChild( xNode, "item", i++ )) { U_TCHAR_MAP *pUserColumn = new U_TCHAR_MAP(10); int j = 1; while ( XmlNode* fieldNode = JabberXmlGetNthChild( itemNode, "field", j++ )) { if (TCHAR * var=JabberXmlGetAttrValue(fieldNode,"var" )) { if (TCHAR * Text=(JabberXmlGetChild(fieldNode,"value")->text)) { if (!mColumnsNames[var]) mColumnsNames.insert(var,var); pUserColumn->insert(var,Text); } } } SearchResults.insert((void*)pUserColumn); } } else { //2. Field list search results info int i=1; while ( XmlNode* itemNode = JabberXmlGetNthChild( queryNode, "item", i++ )) { U_TCHAR_MAP *pUserColumn=new U_TCHAR_MAP(10); TCHAR* jid = JabberXmlGetAttrValue( itemNode, "jid" ); TCHAR* keyReturned; mColumnsNames.insertCopyKey( _T("jid"),_T("jid"),&keyReturned, CopyKey, DestroyKey ); mColumnsNames.insert( _T("jid"), keyReturned ); pUserColumn->insertCopyKey( _T("jid"), jid, NULL, CopyKey, DestroyKey ); for ( int j=0; j < itemNode->numChild; j++ ) { XmlNode* child = itemNode->child[j]; if ( child->name ) { TCHAR * szColumnName=a2t(child->name); if ( child->text && child->text[0] != _T('\0')) { TCHAR *keyReturned; mColumnsNames.insertCopyKey(szColumnName,_T(""),&keyReturned, CopyKey, DestroyKey); mColumnsNames.insert(szColumnName,keyReturned); pUserColumn->insertCopyKey(szColumnName,child->text,NULL, CopyKey, DestroyKey); mir_free(szColumnName); } } } SearchResults.insert((void*)pUserColumn); } } } else if (!lstrcmp( type, _T("error"))) { TCHAR * code=NULL; TCHAR * description=NULL; TCHAR buff[255]; XmlNode* errorNode = JabberXmlGetChild( iqNode, "error" ); if (errorNode) { code = JabberXmlGetAttrValue(errorNode,"code"); description = errorNode->text; } _sntprintf(buff,SIZEOF(buff),TranslateT("Error %s %s\r\nTry to specify more detailed"),code ? code : _T(""),description?description:_T("")); JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); if (searchHandleDlg ) SetDlgItemText(searchHandleDlg,IDC_INSTRUCTIONS,buff); else MessageBox(NULL, buff, TranslateT("Search error"), MB_OK|MB_ICONSTOP); return; } JabberSearchReturnResults((HANDLE)id, (void*)&SearchResults, (U_TCHAR_MAP *)&mColumnsNames); for (int i=0; i < SearchResults.getCount(); i++ ) delete ((U_TCHAR_MAP *)SearchResults[i]); //send success to finish searching JSendBroadcast( NULL, ACKTYPE_SEARCH, ACKRESULT_SUCCESS, ( HANDLE ) id, 0 ); }