summaryrefslogtreecommitdiff
path: root/protocols/JabberG/src/jabber_ibb.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'protocols/JabberG/src/jabber_ibb.cpp')
-rw-r--r--protocols/JabberG/src/jabber_ibb.cpp154
1 files changed, 77 insertions, 77 deletions
diff --git a/protocols/JabberG/src/jabber_ibb.cpp b/protocols/JabberG/src/jabber_ibb.cpp
index 51719a696b..53137d50fc 100644
--- a/protocols/JabberG/src/jabber_ibb.cpp
+++ b/protocols/JabberG/src/jabber_ibb.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
@@ -28,99 +28,99 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#define JABBER_IBB_BLOCK_SIZE 2048
-void JabberIbbFreeJibb( JABBER_IBB_TRANSFER *jibb )
+void JabberIbbFreeJibb(JABBER_IBB_TRANSFER *jibb)
{
- if ( jibb ) {
+ if (jibb) {
filetransfer* pft = jibb->ft;
- if ( pft )
+ if (pft)
pft->jibb = NULL;
- mir_free( jibb->srcJID );
- mir_free( jibb->dstJID );
- mir_free( jibb->sid );
+ mir_free(jibb->srcJID);
+ mir_free(jibb->dstJID);
+ mir_free(jibb->sid);
- mir_free( jibb );
+ mir_free(jibb);
} }
-BOOL CJabberProto::OnFtHandleIbbIq( HXML iqNode, CJabberIqInfo* pInfo )
+BOOL CJabberProto::OnFtHandleIbbIq(HXML iqNode, CJabberIqInfo* pInfo)
{
- if ( !_tcscmp( pInfo->GetChildNodeName(), _T("open")))
- FtHandleIbbRequest( iqNode, TRUE );
- else if ( !_tcscmp( pInfo->GetChildNodeName(), _T("close")))
- FtHandleIbbRequest( iqNode, FALSE );
- else if ( !_tcscmp( pInfo->GetChildNodeName(), _T("data"))) {
+ if ( !_tcscmp(pInfo->GetChildNodeName(), _T("open")))
+ FtHandleIbbRequest(iqNode, TRUE);
+ else if ( !_tcscmp(pInfo->GetChildNodeName(), _T("close")))
+ FtHandleIbbRequest(iqNode, FALSE);
+ else if ( !_tcscmp(pInfo->GetChildNodeName(), _T("data"))) {
BOOL bOk = FALSE;
- const TCHAR *sid = xmlGetAttrValue( pInfo->GetChildNode(), _T("sid"));
- const TCHAR *seq = xmlGetAttrValue( pInfo->GetChildNode(), _T("seq"));
- if ( sid && seq && xmlGetText( pInfo->GetChildNode()))
- bOk = OnIbbRecvdData( xmlGetText( pInfo->GetChildNode()), sid, seq );
+ const TCHAR *sid = xmlGetAttrValue(pInfo->GetChildNode(), _T("sid"));
+ const TCHAR *seq = xmlGetAttrValue(pInfo->GetChildNode(), _T("seq"));
+ if (sid && seq && xmlGetText(pInfo->GetChildNode()))
+ bOk = OnIbbRecvdData(xmlGetText(pInfo->GetChildNode()), sid, seq);
- if ( bOk )
- m_ThreadInfo->send( XmlNodeIq( _T("result"), pInfo ));
+ if (bOk)
+ m_ThreadInfo->send(XmlNodeIq(_T("result"), pInfo));
else
- m_ThreadInfo->send(
- XmlNodeIq( _T("error"), pInfo )
- << XCHILD( _T("error")) << XATTRI( _T("code"), 404 ) << XATTR( _T("type"), _T("cancel"))
- << XCHILDNS( _T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
+ m_ThreadInfo->send(
+ XmlNodeIq(_T("error"), pInfo)
+ << XCHILD(_T("error")) << XATTRI(_T("code"), 404) << XATTR(_T("type"), _T("cancel"))
+ << XCHILDNS(_T("item-not-found"), _T("urn:ietf:params:xml:ns:xmpp-stanzas")));
}
return TRUE;
}
-void CJabberProto::OnIbbInitiateResult( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIbbInitiateResult(HXML, CJabberIqInfo* pInfo)
{
- JABBER_IBB_TRANSFER *jibb = ( JABBER_IBB_TRANSFER * )pInfo->GetUserData();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT )
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
jibb->bStreamInitialized = TRUE;
- if ( jibb->hEvent )
- SetEvent( jibb->hEvent );
+ if (jibb->hEvent)
+ SetEvent(jibb->hEvent);
}
-void CJabberProto::OnIbbCloseResult( HXML, CJabberIqInfo* pInfo )
+void CJabberProto::OnIbbCloseResult(HXML, CJabberIqInfo* pInfo)
{
- JABBER_IBB_TRANSFER *jibb = ( JABBER_IBB_TRANSFER * )pInfo->GetUserData();
- if ( pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT )
+ JABBER_IBB_TRANSFER *jibb = (JABBER_IBB_TRANSFER *)pInfo->GetUserData();
+ if (pInfo->GetIqType() == JABBER_IQ_TYPE_RESULT)
jibb->bStreamClosed = TRUE;
- if ( jibb->hEvent )
- SetEvent( jibb->hEvent );
+ if (jibb->hEvent)
+ SetEvent(jibb->hEvent);
}
-void CJabberProto::IbbSendThread( JABBER_IBB_TRANSFER *jibb )
+void CJabberProto::IbbSendThread(JABBER_IBB_TRANSFER *jibb)
{
- Log( "Thread started: type=ibb_send" );
+ Log("Thread started: type=ibb_send");
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jibb->bStreamInitialized = FALSE;
jibb->bStreamClosed = FALSE;
jibb->state = JIBB_SENDING;
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb ))
- << XCHILDNS( _T("open"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ) << XATTRI( _T("block-size"), JABBER_IBB_BLOCK_SIZE )
- << XATTR( _T("stanza"), _T("message")));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbInitiateResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ << XCHILDNS(_T("open"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid) << XATTRI(_T("block-size"), JABBER_IBB_BLOCK_SIZE)
+ << XATTR(_T("stanza"), _T("message")));
- WaitForSingleObject( jibb->hEvent, INFINITE );
- CloseHandle( jibb->hEvent );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->bStreamInitialized ) {
+ if (jibb->bStreamInitialized) {
jibb->wPacketId = 0;
- BOOL bSent = (this->*jibb->pfnSend)( JABBER_IBB_BLOCK_SIZE, jibb->ft );
+ BOOL bSent = (this->*jibb->pfnSend)(JABBER_IBB_BLOCK_SIZE, jibb->ft);
- if ( !jibb->bStreamClosed )
+ if ( !jibb->bStreamClosed)
{
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
m_ThreadInfo->send(
- XmlNodeIq( m_iqManager.AddHandler( &CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb ))
- << XCHILDNS( _T("close"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ));
+ XmlNodeIq(m_iqManager.AddHandler(&CJabberProto::OnIbbCloseResult, JABBER_IQ_TYPE_SET, jibb->dstJID, 0, -1, jibb))
+ << XCHILDNS(_T("close"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid));
- WaitForSingleObject( jibb->hEvent, INFINITE );
- CloseHandle( jibb->hEvent );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->bStreamClosed && bSent )
+ if (jibb->bStreamClosed && bSent)
jibb->state = JIBB_DONE;
} else {
@@ -128,66 +128,66 @@ void CJabberProto::IbbSendThread( JABBER_IBB_TRANSFER *jibb )
}
}
- (this->*jibb->pfnFinal)(( jibb->state==JIBB_DONE )?TRUE:FALSE, jibb->ft );
+ (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
jibb->ft = NULL;
- JabberIbbFreeJibb( jibb );
+ JabberIbbFreeJibb(jibb);
}
-void __cdecl CJabberProto::IbbReceiveThread( JABBER_IBB_TRANSFER *jibb )
+void __cdecl CJabberProto::IbbReceiveThread(JABBER_IBB_TRANSFER *jibb)
{
- Log( "Thread started: type=ibb_recv" );
+ Log("Thread started: type=ibb_recv");
filetransfer *ft = jibb->ft;
- jibb->hEvent = CreateEvent( NULL, FALSE, FALSE, NULL );
+ jibb->hEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
jibb->bStreamClosed = FALSE;
jibb->wPacketId = 0;
jibb->dwTransferredSize = 0;
jibb->state = JIBB_RECVING;
- WaitForSingleObject( jibb->hEvent, INFINITE );
+ WaitForSingleObject(jibb->hEvent, INFINITE);
- CloseHandle( jibb->hEvent );
+ CloseHandle(jibb->hEvent);
jibb->hEvent = NULL;
- if ( jibb->state == JIBB_ERROR )
- m_ThreadInfo->send( XmlNodeIq( _T("set"), SerialNext(), jibb->dstJID ) << XCHILDNS( _T("close"), _T(JABBER_FEAT_IBB)) << XATTR( _T("sid"), jibb->sid ));
+ if (jibb->state == JIBB_ERROR)
+ m_ThreadInfo->send(XmlNodeIq(_T("set"), SerialNext(), jibb->dstJID) << XCHILDNS(_T("close"), _T(JABBER_FEAT_IBB)) << XATTR(_T("sid"), jibb->sid));
- if ( jibb->bStreamClosed && jibb->dwTransferredSize == ft->dwExpectedRecvFileSize )
+ if (jibb->bStreamClosed && jibb->dwTransferredSize == ft->dwExpectedRecvFileSize)
jibb->state = JIBB_DONE;
- (this->*jibb->pfnFinal)(( jibb->state==JIBB_DONE )?TRUE:FALSE, jibb->ft );
+ (this->*jibb->pfnFinal)((jibb->state==JIBB_DONE)?TRUE:FALSE, jibb->ft);
jibb->ft = NULL;
- ListRemove( LIST_FTRECV, jibb->sid );
+ ListRemove(LIST_FTRECV, jibb->sid);
- JabberIbbFreeJibb( jibb );
+ JabberIbbFreeJibb(jibb);
}
-BOOL CJabberProto::OnIbbRecvdData( const TCHAR *data, const TCHAR *sid, const TCHAR *seq )
+BOOL CJabberProto::OnIbbRecvdData(const TCHAR *data, const TCHAR *sid, const TCHAR *seq)
{
- JABBER_LIST_ITEM *item = ListGetItemPtr( LIST_FTRECV, sid );
- if ( !item ) return FALSE;
+ JABBER_LIST_ITEM *item = ListGetItemPtr(LIST_FTRECV, sid);
+ if ( !item) return FALSE;
WORD wSeq = (WORD)_ttoi(seq);
- if ( wSeq != item->jibb->wPacketId ) {
- if ( item->jibb->hEvent )
- SetEvent( item->jibb->hEvent );
+ if (wSeq != item->jibb->wPacketId) {
+ if (item->jibb->hEvent)
+ SetEvent(item->jibb->hEvent);
return FALSE;
}
item->jibb->wPacketId++;
int length = 0;
- char *decodedData = JabberBase64DecodeT( data, &length );
- if ( !decodedData )
+ char *decodedData = JabberBase64DecodeT(data, &length);
+ if ( !decodedData)
return FALSE;
- (this->*item->jibb->pfnRecv)( NULL, item->ft, decodedData, length );
+ (this->*item->jibb->pfnRecv)(NULL, item->ft, decodedData, length);
item->jibb->dwTransferredSize += (DWORD)length;
- mir_free( decodedData );
+ mir_free(decodedData);
return TRUE;
}