From b81bfbf62c6a3e2a977167fd041a989f609b16ea Mon Sep 17 00:00:00 2001 From: Kirill Volinsky Date: Mon, 19 Aug 2013 07:37:30 +0000 Subject: replace jabber to tlen git-svn-id: http://svn.miranda-ng.org/main/trunk@5742 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- protocols/Tlen/src/tlen.cpp | 8 +- protocols/Tlen/src/tlen.h | 164 +++++------ protocols/Tlen/src/tlen_advsearch.cpp | 12 +- protocols/Tlen/src/tlen_avatar.cpp | 36 +-- protocols/Tlen/src/tlen_avatar.h | 6 +- protocols/Tlen/src/tlen_file.cpp | 192 ++++++------- protocols/Tlen/src/tlen_iq.cpp | 26 +- protocols/Tlen/src/tlen_iq.h | 30 +- protocols/Tlen/src/tlen_iqid.cpp | 208 +++++++------- protocols/Tlen/src/tlen_list.cpp | 80 +++--- protocols/Tlen/src/tlen_list.h | 50 ++-- protocols/Tlen/src/tlen_misc.cpp | 30 +- protocols/Tlen/src/tlen_muc.cpp | 264 ++++++++--------- protocols/Tlen/src/tlen_opt.cpp | 8 +- protocols/Tlen/src/tlen_p2p_new.cpp | 96 +++---- protocols/Tlen/src/tlen_p2p_old.cpp | 72 ++--- protocols/Tlen/src/tlen_p2p_old.h | 10 +- protocols/Tlen/src/tlen_picture.cpp | 84 +++--- protocols/Tlen/src/tlen_presence.cpp | 86 +++--- protocols/Tlen/src/tlen_svc.cpp | 258 ++++++++--------- protocols/Tlen/src/tlen_thread.cpp | 524 +++++++++++++++++----------------- protocols/Tlen/src/tlen_userinfo.cpp | 38 +-- protocols/Tlen/src/tlen_util.cpp | 48 ++-- protocols/Tlen/src/tlen_voice.cpp | 152 +++++----- protocols/Tlen/src/tlen_ws.cpp | 28 +- protocols/Tlen/src/tlen_xml.cpp | 76 ++--- protocols/Tlen/src/tlen_xml.h | 32 +-- 27 files changed, 1309 insertions(+), 1309 deletions(-) (limited to 'protocols/Tlen/src') diff --git a/protocols/Tlen/src/tlen.cpp b/protocols/Tlen/src/tlen.cpp index 1206d4016c..61ca7c8d3b 100644 --- a/protocols/Tlen/src/tlen.cpp +++ b/protocols/Tlen/src/tlen.cpp @@ -117,7 +117,7 @@ int TlenProtocol::PrebuildContactMenu(WPARAM wParam, LPARAM lParam) if (hContact != NULL && isOnline) { DBVARIANT dbv; if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - JABBER_LIST_ITEM *item = JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal); + TLEN_LIST_ITEM *item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal); db_free(&dbv); if (item != NULL) { Menu_ShowItem(hMenuContactRequestAuth, item->subscription == SUB_NONE || item->subscription == SUB_FROM); @@ -143,7 +143,7 @@ INT_PTR TlenProtocol::ContactMenuHandleRequestAuth(WPARAM wParam, LPARAM lParam) if (hContact != NULL && isOnline) { DBVARIANT dbv; if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - JabberSend(this, "", dbv.pszVal); + TlenSend(this, "", dbv.pszVal); db_free(&dbv); } } @@ -156,7 +156,7 @@ INT_PTR TlenProtocol::ContactMenuHandleGrantAuth(WPARAM wParam, LPARAM lParam) if (hContact != NULL && isOnline) { DBVARIANT dbv; if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - JabberSend(this, "", dbv.pszVal); + TlenSend(this, "", dbv.pszVal); db_free(&dbv); } } @@ -263,7 +263,7 @@ int TlenProtocol::OnModulesLoaded(WPARAM wParam, LPARAM lParam) int TlenProtocol::PreShutdown(WPARAM wParam, LPARAM lParam) { - JabberLog(this, "TLEN TlenPreShutdown"); + TlenLog(this, "TLEN TlenPreShutdown"); return 0; } diff --git a/protocols/Tlen/src/tlen.h b/protocols/Tlen/src/tlen.h index c2caef4230..0b7520b1af 100644 --- a/protocols/Tlen/src/tlen.h +++ b/protocols/Tlen/src/tlen.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _JABBER_H_ -#define _JABBER_H_ +#ifndef _TLEN_H_ +#define _TLEN_H_ #define MIRANDA_VER 0x0A00 @@ -91,29 +91,29 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * Global constants *******************************************************************/ #define TLEN_DEFAULT_PORT 443 -#define JABBER_IQID "mim_" +#define TLEN_IQID "mim_" #define TLEN_REGISTER "http://reg.tlen.pl/" #define TLEN_MAX_SEARCH_RESULTS_PER_PAGE 20 // User-defined message #define WM_TLEN_REFRESH (WM_USER + 100) // Error code -#define JABBER_ERROR_REDIRECT 302 -#define JABBER_ERROR_BAD_REQUEST 400 -#define JABBER_ERROR_UNAUTHORIZED 401 -#define JABBER_ERROR_PAYMENT_REQUIRED 402 -#define JABBER_ERROR_FORBIDDEN 403 -#define JABBER_ERROR_NOT_FOUND 404 -#define JABBER_ERROR_NOT_ALLOWED 405 -#define JABBER_ERROR_NOT_ACCEPTABLE 406 -#define JABBER_ERROR_REGISTRATION_REQUIRED 407 -#define JABBER_ERROR_REQUEST_TIMEOUT 408 -#define JABBER_ERROR_CONFLICT 409 -#define JABBER_ERROR_INTERNAL_SERVER_ERROR 500 -#define JABBER_ERROR_NOT_IMPLEMENTED 501 -#define JABBER_ERROR_REMOTE_SERVER_ERROR 502 -#define JABBER_ERROR_SERVICE_UNAVAILABLE 503 -#define JABBER_ERROR_REMOTE_SERVER_TIMEOUT 504 +#define TLEN_ERROR_REDIRECT 302 +#define TLEN_ERROR_BAD_REQUEST 400 +#define TLEN_ERROR_UNAUTHORIZED 401 +#define TLEN_ERROR_PAYMENT_REQUIRED 402 +#define TLEN_ERROR_FORBIDDEN 403 +#define TLEN_ERROR_NOT_FOUND 404 +#define TLEN_ERROR_NOT_ALLOWED 405 +#define TLEN_ERROR_NOT_ACCEPTABLE 406 +#define TLEN_ERROR_REGISTRATION_REQUIRED 407 +#define TLEN_ERROR_REQUEST_TIMEOUT 408 +#define TLEN_ERROR_CONFLICT 409 +#define TLEN_ERROR_INTERNAL_SERVER_ERROR 500 +#define TLEN_ERROR_NOT_IMPLEMENTED 501 +#define TLEN_ERROR_REMOTE_SERVER_ERROR 502 +#define TLEN_ERROR_SERVICE_UNAVAILABLE 503 +#define TLEN_ERROR_REMOTE_SERVER_TIMEOUT 504 #define TLEN_ALERTS_ACCEPT_ALL 0 #define TLEN_ALERTS_IGNORE_NIR 1 @@ -134,7 +134,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /******************************************************************* * Global data structures and data type definitions *******************************************************************/ -typedef HANDLE JABBER_SOCKET; +typedef HANDLE TLEN_SOCKET; typedef enum { LIST_ROSTER, // Roster list @@ -144,19 +144,19 @@ typedef enum { LIST_SEARCH, // Rooms names being searched LIST_VOICE, LIST_PICTURE -} JABBER_LIST; +} TLEN_LIST; typedef enum { IQ_PROC_NONE, IQ_PROC_GETSEARCH -} JABBER_IQ_PROCID; +} TLEN_IQ_PROCID; typedef enum { SUB_NONE, SUB_TO, SUB_FROM, SUB_BOTH -} JABBER_SUBSCRIPTION; +} TLEN_SUBSCRIPTION; typedef struct { char *szOnline; @@ -165,7 +165,7 @@ typedef struct { char *szDnd; char *szFreechat; char *szInvisible; -} JABBER_MODEMSGS; +} TLEN_MODEMSGS; typedef struct { char mailBase[256]; @@ -207,8 +207,8 @@ typedef struct { } TlenOptions; -struct JABBER_IQ_FUNC_STRUCT; -struct JABBER_LIST_ITEM_STRUCT; +struct TLEN_IQ_FUNC_STRUCT; +struct TLEN_LIST_ITEM_STRUCT; struct TLEN_VOICE_CONTROL_STRUCT; struct TlenProtocol : public PROTO @@ -292,8 +292,8 @@ struct TlenProtocol : public PROTO int __cdecl OnModulesLoaded(WPARAM wParam, LPARAM lParam); int __cdecl OptionsInit(WPARAM wParam, LPARAM lParam); - int __cdecl JabberDbSettingChanged(WPARAM wParam, LPARAM lParam); - int __cdecl JabberContactDeleted(WPARAM wParam, LPARAM lParam); + int __cdecl TlenDbSettingChanged(WPARAM wParam, LPARAM lParam); + int __cdecl TlenContactDeleted(WPARAM wParam, LPARAM lParam); int __cdecl PrebuildContactMenu(WPARAM wParam, LPARAM lParam); int __cdecl PreShutdown(WPARAM wParam, LPARAM lParam); @@ -305,7 +305,7 @@ struct TlenProtocol : public PROTO HANDLE hNetlibUser; HANDLE hFileNetlibUser; - JABBER_MODEMSGS modeMsgs; + TLEN_MODEMSGS modeMsgs; struct ThreadDataStruct *threadData; HANDLE hTlenNudge; @@ -319,12 +319,12 @@ struct TlenProtocol : public PROTO HGENMENU hMenuPicture; int listsCount; - struct JABBER_LIST_ITEM_STRUCT *lists; + struct TLEN_LIST_ITEM_STRUCT *lists; CRITICAL_SECTION csLists; int iqCount; int iqAlloced; - struct JABBER_IQ_FUNC_STRUCT *iqList; + struct TLEN_IQ_FUNC_STRUCT *iqList; CRITICAL_SECTION csIqList; CRITICAL_SECTION csSerial; @@ -370,7 +370,7 @@ typedef struct ThreadDataStruct{ WORD port; BOOL useEncryption; - JABBER_SOCKET s; //HANDLE from CallService(MS_NETLIB_OPENCONNECTION (jabber_ws.c:68) + TLEN_SOCKET s; //HANDLE from CallService(MS_NETLIB_OPENCONNECTION (tlen_ws.c:68) aes_context aes_in_context; aes_context aes_out_context; unsigned char aes_in_iv[16]; @@ -382,13 +382,13 @@ typedef struct ThreadDataStruct{ } ThreadData; -typedef enum { FT_CONNECTING, FT_INITIALIZING, FT_RECEIVING, FT_DONE, FT_ERROR, FT_DENIED, FT_SWITCH } JABBER_FILE_STATE; -typedef enum { FT_RECV, FT_SEND} JABBER_FILE_MODE; +typedef enum { FT_CONNECTING, FT_INITIALIZING, FT_RECEIVING, FT_DONE, FT_ERROR, FT_DENIED, FT_SWITCH } TLEN_FILE_STATE; +typedef enum { FT_RECV, FT_SEND} TLEN_FILE_MODE; typedef struct TLEN_FILE_TRANSFER_STRUCT{ HANDLE hContact; - JABBER_SOCKET s; + TLEN_SOCKET s; NETLIBNEWCONNECTIONPROC_V2 pfnNewConnectionV2; - JABBER_FILE_STATE state; + TLEN_FILE_STATE state; char *jid; int fileId; char *iqId; @@ -427,7 +427,7 @@ typedef struct TLEN_FILE_TRANSFER_STRUCT{ typedef struct { PROTOSEARCHRESULT hdr; char jid[256]; -} JABBER_SEARCH_RESULT; +} TLEN_SEARCH_RESULT; typedef struct { char *iqId; @@ -439,7 +439,7 @@ typedef struct { typedef struct { int id; TCHAR *name; -} JABBER_FIELD_MAP; +} TLEN_FIELD_MAP; /******************************************************************* @@ -455,63 +455,63 @@ void uninitMenuItems(TlenProtocol *proto); HICON GetIcolibIcon(int iconId); void ReleaseIcolibIcon(HICON hIcon); -void JabberLog(TlenProtocol *proto, const char *fmt, ...); -void __cdecl JabberServerThread(ThreadData *info); -// jabber_ws.cpp -BOOL JabberWsInit(TlenProtocol *proto); -void JabberWsUninit(TlenProtocol *proto); -JABBER_SOCKET JabberWsConnect(TlenProtocol *proto, char *host, WORD port); -int JabberWsSend(TlenProtocol *proto, JABBER_SOCKET s, char *data, int datalen); -int JabberWsRecv(TlenProtocol *proto, JABBER_SOCKET s, char *data, long datalen); -int JabberWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes_ctx, unsigned char *aes_iv); -int JabberWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *aes_ctx, unsigned char *aes_iv); - -// jabber_util.cpp -void JabberSerialInit(TlenProtocol *proto); -void JabberSerialUninit(TlenProtocol *proto); -unsigned int JabberSerialNext(TlenProtocol *proto); -int JabberSend(TlenProtocol *proto, const char *fmt, ...); -HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid); -char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact); -char *JabberLoginFromJID(const char *jid); -char *JabberResourceFromJID(const char *jid); -char *JabberNickFromJID(const char *jid); -char *JabberLocalNickFromJID(const char *jid); +void TlenLog(TlenProtocol *proto, const char *fmt, ...); +void __cdecl TlenServerThread(ThreadData *info); +// tlen_ws.cpp +BOOL TlenWsInit(TlenProtocol *proto); +void TlenWsUninit(TlenProtocol *proto); +TLEN_SOCKET TlenWsConnect(TlenProtocol *proto, char *host, WORD port); +int TlenWsSend(TlenProtocol *proto, TLEN_SOCKET s, char *data, int datalen); +int TlenWsRecv(TlenProtocol *proto, TLEN_SOCKET s, char *data, long datalen); +int TlenWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes_ctx, unsigned char *aes_iv); +int TlenWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *aes_ctx, unsigned char *aes_iv); + +// tlen_util.cpp +void TlenSerialInit(TlenProtocol *proto); +void TlenSerialUninit(TlenProtocol *proto); +unsigned int TlenSerialNext(TlenProtocol *proto); +int TlenSend(TlenProtocol *proto, const char *fmt, ...); +HANDLE TlenHContactFromJID(TlenProtocol *proto, const char *jid); +char *TlenJIDFromHContact(TlenProtocol *proto, HANDLE hContact); +char *TlenLoginFromJID(const char *jid); +char *TlenResourceFromJID(const char *jid); +char *TlenNickFromJID(const char *jid); +char *TlenLocalNickFromJID(const char *jid); char *TlenGroupEncode(const char *str); char *TlenGroupDecode(const char *str); -char *JabberSha1(char *str); +char *TlenSha1(char *str); char *TlenSha1(char *str, int len); char *TlenPasswordHash(const char *str); void TlenUrlDecode(char *str); char *TlenUrlEncode(const char *str); -char *JabberTextEncode(const char *str); -char *JabberTextDecode(const char *str); +char *TlenTextEncode(const char *str); +char *TlenTextDecode(const char *str); void TlenLogMessage(TlenProtocol *proto, HANDLE hContact, DWORD flags, const char *message); BOOL IsAuthorized(TlenProtocol *proto, const char *jid); -//char *JabberGetVersionText(); -time_t JabberIsoToUnixTime(char *stamp); +//char *TlenGetVersionText(); +time_t TlenIsoToUnixTime(char *stamp); time_t TlenTimeToUTC(time_t time); -void JabberSendPresence(TlenProtocol *proto,int status); -void JabberStringAppend(char **str, int *sizeAlloced, const char *fmt, ...); -//char *JabberGetClientJID(char *jid); -// jabber_misc.cpp -void JabberDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob); -void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick); -HANDLE JabberDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary); -void JabberContactListCreateGroup(char *groupName); -unsigned long JabberForkThread(void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg); -// jabber_svc.cpp +void TlenSendPresence(TlenProtocol *proto,int status); +void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...); +//char *TlenGetClientJID(char *jid); +// tlen_misc.cpp +void TlenDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob); +void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick); +HANDLE TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary); +void TlenContactListCreateGroup(char *groupName); +unsigned long TlenForkThread(void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg); +// tlen_svc.cpp int TlenRunSearch(TlenProtocol *proto); -// jabber_opt.cpp +// tlen_opt.cpp void TlenLoadOptions(TlenProtocol *proto); // tlen_voice.cpp int TlenVoiceCancelAll(TlenProtocol *proto); -// jabber_advsearch.cpp -extern JABBER_FIELD_MAP tlenFieldGender[]; -extern JABBER_FIELD_MAP tlenFieldLookfor[]; -extern JABBER_FIELD_MAP tlenFieldStatus[]; -extern JABBER_FIELD_MAP tlenFieldOccupation[]; -extern JABBER_FIELD_MAP tlenFieldPlan[]; +// tlen_advsearch.cpp +extern TLEN_FIELD_MAP tlenFieldGender[]; +extern TLEN_FIELD_MAP tlenFieldLookfor[]; +extern TLEN_FIELD_MAP tlenFieldStatus[]; +extern TLEN_FIELD_MAP tlenFieldOccupation[]; +extern TLEN_FIELD_MAP tlenFieldPlan[]; // tlen_advsearch.cpp INT_PTR CALLBACK TlenAdvSearchDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); char *TlenAdvSearchCreateQuery(HWND hwndDlg, int iqId); diff --git a/protocols/Tlen/src/tlen_advsearch.cpp b/protocols/Tlen/src/tlen_advsearch.cpp index 92611ac126..33d7e907a9 100644 --- a/protocols/Tlen/src/tlen_advsearch.cpp +++ b/protocols/Tlen/src/tlen_advsearch.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen.h" #include "resource.h" -static void InitComboBox(HWND hwndCombo, JABBER_FIELD_MAP *fieldMap) +static void InitComboBox(HWND hwndCombo, TLEN_FIELD_MAP *fieldMap) { int i, n; @@ -63,9 +63,9 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i return; GetDlgItemTextA(hwndDlg, idCtrl, text, sizeof(text)); if (text[0]) { - if ((localFieldName=JabberTextEncode(fieldName)) != NULL) { - if ((localText=JabberTextEncode(text)) != NULL) { - JabberStringAppend(str, strSize, "<%s>%s", localFieldName, localText, localFieldName); + if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { + if ((localText=TlenTextEncode(text)) != NULL) { + TlenStringAppend(str, strSize, "<%s>%s", localFieldName, localText, localFieldName); mir_free(localText); } mir_free(localFieldName); @@ -82,8 +82,8 @@ static void FetchCombo(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i return; value = (int) SendDlgItemMessage(hwndDlg, idCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, idCtrl, CB_GETCURSEL, 0, 0), 0); if (value > 0) { - if ((localFieldName=JabberTextEncode(fieldName)) != NULL) { - JabberStringAppend(str, strSize, "<%s>%d", localFieldName, value, localFieldName); + if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { + TlenStringAppend(str, strSize, "<%s>%d", localFieldName, value, localFieldName); mir_free(localFieldName); } } diff --git a/protocols/Tlen/src/tlen_avatar.cpp b/protocols/Tlen/src/tlen_avatar.cpp index a55c0321f0..f832ba9188 100644 --- a/protocols/Tlen/src/tlen_avatar.cpp +++ b/protocols/Tlen/src/tlen_avatar.cpp @@ -31,7 +31,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. /* TlenGetAvatarFileName() - gets a file name for the avatar image */ -void TlenGetAvatarFileName(TlenProtocol *proto, JABBER_LIST_ITEM *item, TCHAR* ptszDest, int cbLen) +void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* ptszDest, int cbLen) { int format = PA_FORMAT_PNG; TCHAR* tmpPath = Utils_ReplaceVarsT( TEXT("%miranda_avatarcache%") ); @@ -51,7 +51,7 @@ void TlenGetAvatarFileName(TlenProtocol *proto, JABBER_LIST_ITEM *item, TCHAR* p const TCHAR *tszFileType = ProtoGetAvatarExtension(format); if ( item != NULL ) - mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S%s"), ptrA( JabberSha1(item->jid)), tszFileType); + mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S%s"), ptrA( TlenSha1(item->jid)), tszFileType); else mir_sntprintf(ptszDest + tPathLen, MAX_PATH - tPathLen, TEXT("%S_avatar%s"), proto->m_szModuleName, tszFileType); } @@ -69,7 +69,7 @@ static void RemoveAvatar(TlenProtocol *proto, HANDLE hContact) { ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL, 0); } -static void SetAvatar(TlenProtocol *proto, HANDLE hContact, JABBER_LIST_ITEM *item, char *data, int len, DWORD format) { +static void SetAvatar(TlenProtocol *proto, HANDLE hContact, TLEN_LIST_ITEM *item, char *data, int len, DWORD format) { TCHAR filename[MAX_PATH]; char md5[33]; mir_md5_state_t ctx; @@ -105,14 +105,14 @@ static void SetAvatar(TlenProtocol *proto, HANDLE hContact, JABBER_LIST_ITEM *it ProtoBroadcastAck( proto->m_szModuleName, hContact, ACKTYPE_AVATAR, ACKRESULT_STATUS, NULL , 0); } -int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, JABBER_LIST_ITEM *item) { +int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, TLEN_LIST_ITEM *item) { XmlNode *aNode; char *oldHash = NULL; char *md5 = NULL, *type = NULL; HANDLE hContact; hContact = NULL; if (item != NULL) { - if ((hContact=JabberHContactFromJID(proto, item->jid)) == NULL) return 0; + if ((hContact=TlenHContactFromJID(proto, item->jid)) == NULL) return 0; } if (item == NULL) { oldHash = proto->threadData->avatarHash; @@ -120,10 +120,10 @@ int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, JABBER_LIST_ oldHash = item->avatarHash; } if (avatarNode != NULL) { - aNode = JabberXmlGetChild(avatarNode, "a"); + aNode = TlenXmlGetChild(avatarNode, "a"); if (aNode != NULL) { - type = JabberXmlGetAttrValue(aNode, "type"); - md5 = JabberXmlGetAttrValue(aNode, "md5"); + type = TlenXmlGetAttrValue(aNode, "type"); + md5 = TlenXmlGetAttrValue(aNode, "md5"); } } if (md5 != NULL) { @@ -150,10 +150,10 @@ int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, JABBER_LIST_ return 0; } -void TlenProcessPresenceAvatar(TlenProtocol *proto, XmlNode *node, JABBER_LIST_ITEM *item) { +void TlenProcessPresenceAvatar(TlenProtocol *proto, XmlNode *node, TLEN_LIST_ITEM *item) { HANDLE hContact; - if ((hContact=JabberHContactFromJID(proto, item->jid)) == NULL) return; - TlenProcessAvatarNode(proto, JabberXmlGetChild(node, "avatar"), item); + if ((hContact=TlenHContactFromJID(proto, item->jid)) == NULL) return; + TlenProcessAvatarNode(proto, TlenXmlGetChild(node, "avatar"), item); } @@ -216,7 +216,7 @@ typedef struct { static void TlenGetAvatarThread(void *ptr) { - JABBER_LIST_ITEM *item = NULL; + TLEN_LIST_ITEM *item = NULL; NETLIBHTTPREQUEST req; NETLIBHTTPREQUEST *resp; TLENGETAVATARTHREADDATA *data = (TLENGETAVATARTHREADDATA *)ptr; @@ -224,9 +224,9 @@ static void TlenGetAvatarThread(void *ptr) { char *request; char *login = NULL; if (hContact != NULL) { - char *jid = JabberJIDFromHContact(data->proto, hContact); - login = JabberNickFromJID(jid); - item = JabberListGetItemPtr(data->proto, LIST_ROSTER, jid); + char *jid = TlenJIDFromHContact(data->proto, hContact); + login = TlenNickFromJID(jid); + item = TlenListGetItemPtr(data->proto, LIST_ROSTER, jid); mir_free(jid); } else { login = mir_strdup(data->proto->threadData->username); @@ -298,7 +298,7 @@ void TlenGetAvatar(TlenProtocol *proto, HANDLE hContact) { TLENGETAVATARTHREADDATA *data = (TLENGETAVATARTHREADDATA *)mir_alloc(sizeof(TLENGETAVATARTHREADDATA)); data->proto = proto; data->hContact = hContact; - JabberForkThread(TlenGetAvatarThread, 0, data); + TlenForkThread(TlenGetAvatarThread, 0, data); } } @@ -361,7 +361,7 @@ void TlenRemoveAvatar(TlenProtocol *proto) { req->cbSize = sizeof(NETLIBHTTPREQUEST); req->requestType = proto->threadData->tlenConfig.avatarGetMthd; req->szUrl = request; - JabberForkThread(TlenRemoveAvatarRequestThread, 0, data); + TlenForkThread(TlenRemoveAvatarRequestThread, 0, data); } } @@ -401,7 +401,7 @@ void TlenUploadAvatar(TlenProtocol *proto, unsigned char *data, int dataLen, int threadData->data = (char *) mir_alloc(dataLen); memcpy(threadData->data, data, dataLen); threadData->length = dataLen; - JabberForkThread(TlenUploadAvatarRequestThread, 0, threadData); + TlenForkThread(TlenUploadAvatarRequestThread, 0, threadData); } } diff --git a/protocols/Tlen/src/tlen_avatar.h b/protocols/Tlen/src/tlen_avatar.h index 0a0694fe11..1db81cd3a7 100644 --- a/protocols/Tlen/src/tlen_avatar.h +++ b/protocols/Tlen/src/tlen_avatar.h @@ -24,9 +24,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #ifndef _TLEN_AVATAR_H_ #define _TLEN_AVATAR_H_ -void TlenProcessPresenceAvatar(TlenProtocol *proto, XmlNode *node, JABBER_LIST_ITEM *item); -int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, JABBER_LIST_ITEM *item); -void TlenGetAvatarFileName(TlenProtocol *proto, JABBER_LIST_ITEM *item, TCHAR* psztDest, int cbLen); +void TlenProcessPresenceAvatar(TlenProtocol *proto, XmlNode *node, TLEN_LIST_ITEM *item); +int TlenProcessAvatarNode(TlenProtocol *proto, XmlNode *avatarNode, TLEN_LIST_ITEM *item); +void TlenGetAvatarFileName(TlenProtocol *proto, TLEN_LIST_ITEM *item, TCHAR* psztDest, int cbLen); void TlenGetAvatar(TlenProtocol *proto, HANDLE hContact); void TlenUploadAvatar(TlenProtocol *proto, unsigned char *data, int dataLen, int access); void TlenRemoveAvatar(TlenProtocol *proto); diff --git a/protocols/Tlen/src/tlen_file.cpp b/protocols/Tlen/src/tlen_file.cpp index 81bbbf298f..2bfb56f791 100644 --- a/protocols/Tlen/src/tlen_file.cpp +++ b/protocols/Tlen/src/tlen_file.cpp @@ -62,7 +62,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) TlenP2PPacketSend(ft->s, packet); TlenP2PPacketFree(packet); ft->state = FT_INITIALIZING; - JabberLog(ft->proto, "Change to FT_INITIALIZING"); + TlenLog(ft->proto, "Change to FT_INITIALIZING"); } } TlenP2PPacketFree(rpacket); @@ -89,10 +89,10 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) ft->fileId = _open(fullFileName, _O_BINARY|_O_WRONLY|_O_CREAT|_O_TRUNC, _S_IREAD|_S_IWRITE); ft->fileReceivedBytes = 0; ft->fileTotalSize = ft->filesSize[ft->currentFile]; - JabberLog(ft->proto, "Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]); + TlenLog(ft->proto, "Saving to [%s] [%d]", fullFileName, ft->filesSize[ft->currentFile]); mir_free(fullFileName); ft->state = FT_RECEIVING; - JabberLog(ft->proto, "Change to FT_RECEIVING"); + TlenLog(ft->proto, "Change to FT_RECEIVING"); } else { ft->state = FT_ERROR; @@ -111,7 +111,7 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) pfts.szCurrentFile = ft->files[ft->currentFile]; pfts.currentFileSize = ft->filesSize[ft->currentFile]; pfts.currentFileTime = 0; - JabberLog(ft->proto, "Receiving data..."); + TlenLog(ft->proto, "Receiving data..."); while (ft->state == FT_RECEIVING) { rpacket = TlenP2PPacketReceive(ft->s); if (rpacket != NULL) { @@ -132,14 +132,14 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) } else if (rpacket->type == TLEN_FILE_PACKET_END_OF_FILE) { // end of file _close(ft->fileId); - JabberLog(ft->proto, "Finishing this file..."); + TlenLog(ft->proto, "Finishing this file..."); if (ft->currentFile >= ft->fileCount-1) { ft->state = FT_DONE; } else { ft->currentFile++; ft->state = FT_INITIALIZING; - JabberLog(ft->proto, "File received, advancing to the next file..."); + TlenLog(ft->proto, "File received, advancing to the next file..."); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); } } @@ -152,9 +152,9 @@ static void TlenFileReceiveParse(TLEN_FILE_TRANSFER *ft) } } -static void TlenFileReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) +static void TlenFileReceivingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) { - JABBER_SOCKET slisten; + TLEN_SOCKET slisten; TLEN_FILE_TRANSFER *ft; TlenProtocol *proto = (TlenProtocol *)pExtra; @@ -162,8 +162,8 @@ static void TlenFileReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemot if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - JabberLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); - JabberLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); + TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); + TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileReceiveParse(ft); } @@ -171,9 +171,9 @@ static void TlenFileReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemot ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - JabberLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - JabberLog(ft->proto, "ft->s is restored to %d", ft->s); + TlenLog(ft->proto, "ft->s is restored to %d", ft->s); if (ft->s != hConnection) { Netlib_CloseHandle(hConnection); } @@ -188,8 +188,8 @@ static void TlenFileReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemot static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) { NETLIBOPENCONNECTION nloc; - JABBER_SOCKET s; - JabberLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); + TLEN_SOCKET s; + TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); ft->mode = FT_RECV; nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = ft->hostName; @@ -199,7 +199,7 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc); if (s != NULL) { ft->s = s; - JabberLog(ft->proto, "Entering file receive loop"); + TlenLog(ft->proto, "Entering file receive loop"); TlenP2PEstablishOutgoingConnection(ft, TRUE); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileReceiveParse(ft); @@ -210,7 +210,7 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) ft->s = NULL; } else { ft->pfnNewConnectionV2 = TlenFileReceivingConnection; - JabberLog(ft->proto, "Connection failed - receiving as server"); + TlenLog(ft->proto, "Connection failed - receiving as server"); s = TlenP2PListen(ft); if (s != NULL) { HANDLE hEvent; @@ -220,31 +220,31 @@ static void __cdecl TlenFileReceiveThread(TLEN_FILE_TRANSFER *ft) ft->hFileEvent = hEvent; ft->currentFile = 0; ft->state = FT_CONNECTING; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - JabberLog(ft->proto, "Waiting for the file to be received..."); + TlenLog(ft->proto, "Waiting for the file to be received..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - JabberLog(ft->proto, "Finish all files"); + TlenLog(ft->proto, "Finish all files"); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; } } - JabberListRemove(ft->proto, LIST_FILE, ft->iqId); + TlenListRemove(ft->proto, LIST_FILE, ft->iqId); if (ft->state == FT_DONE) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else { char *nick; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - JabberLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); + TlenLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); TlenP2PFreeFileTransfer(ft); } @@ -286,7 +286,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) ft->allFileReceivedBytes = 0; ft->state = FT_INITIALIZING; - JabberLog(ft->proto, "Change to FT_INITIALIZING"); + TlenLog(ft->proto, "Change to FT_INITIALIZING"); } else { ft->state = FT_ERROR; @@ -294,12 +294,12 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) } else if (ft->state == FT_INITIALIZING) { // FT_INITIALIZING rpacket = TlenP2PPacketReceive(ft->s); - JabberLog(ft->proto, "FT_INITIALIZING: recv %d", rpacket); + TlenLog(ft->proto, "FT_INITIALIZING: recv %d", rpacket); if (rpacket == NULL) { ft->state = FT_ERROR; return; } - JabberLog(ft->proto, "FT_INITIALIZING: recv type %d", rpacket->type); + TlenLog(ft->proto, "FT_INITIALIZING: recv type %d", rpacket->type); p = rpacket->packet; // TYPE: TLEN_FILE_PACKET_FILE_LIST_ACK will be ignored // LEN: 0 @@ -318,14 +318,14 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) currentFile = *((DWORD*)p); if (currentFile != ft->currentFile) { - JabberLog(ft->proto, "Requested file (#%d) is invalid (must be %d)", currentFile, ft->currentFile); + TlenLog(ft->proto, "Requested file (#%d) is invalid (must be %d)", currentFile, ft->currentFile); ft->state = FT_ERROR; } else { // _stat(ft->files[currentFile], &statbuf); // file size in statbuf.st_size - JabberLog(ft->proto, "Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]); + TlenLog(ft->proto, "Sending [%s] [%d]", ft->files[currentFile], ft->filesSize[currentFile]); if ((ft->fileId=_open(ft->files[currentFile], _O_BINARY|_O_RDONLY)) < 0) { - JabberLog(ft->proto, "File cannot be opened"); + TlenLog(ft->proto, "File cannot be opened"); ft->state = FT_ERROR; } else { @@ -348,7 +348,7 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) else { TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_FILE_DATA); fileBuffer = (char *) mir_alloc(2048); - JabberLog(ft->proto, "Sending file data..."); + TlenLog(ft->proto, "Sending file data..."); while ((numRead=_read(ft->fileId, fileBuffer, 2048)) > 0) { TlenP2PPacketSetLen(packet, 0); // Reuse packet TlenP2PPacketPackDword(packet, (DWORD) ft->fileReceivedBytes); @@ -374,11 +374,11 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) else { ft->currentFile++; ft->state = FT_INITIALIZING; - JabberLog(ft->proto, "File sent, advancing to the next file..."); + TlenLog(ft->proto, "File sent, advancing to the next file..."); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_NEXTFILE, ft, 0); } } - JabberLog(ft->proto, "Finishing this file..."); + TlenLog(ft->proto, "Finishing this file..."); TlenP2PPacketSetLen(packet, 0); // Reuse packet TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_END_OF_FILE); TlenP2PPacketPackDword(packet, currentFile); @@ -395,9 +395,9 @@ static void TlenFileSendParse(TLEN_FILE_TRANSFER *ft) } } -static void TlenFileSendingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) +static void TlenFileSendingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) { - JABBER_SOCKET slisten; + TLEN_SOCKET slisten; TLEN_FILE_TRANSFER *ft; TlenProtocol *proto = (TlenProtocol *)pExtra; @@ -405,9 +405,9 @@ static void TlenFileSendingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteI if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - JabberLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); + TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); - JabberLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); + TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileSendParse(ft); } @@ -415,9 +415,9 @@ static void TlenFileSendingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteI ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - JabberLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - JabberLog(ft->proto, "ft->s is restored to %d", ft->s); + TlenLog(ft->proto, "ft->s is restored to %d", ft->s); if (ft->s != hConnection) { Netlib_CloseHandle(hConnection); } @@ -430,18 +430,18 @@ static void TlenFileSendingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteI int TlenFileCancelAll(TlenProtocol *proto) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; HANDLE hEvent; int i = 0; - while ((i=JabberListFindNext(proto, LIST_FILE, 0)) >=0 ) { - if ((item=JabberListGetItemPtrFromIndex(proto, i)) != NULL) { + while ((i=TlenListFindNext(proto, LIST_FILE, 0)) >=0 ) { + if ((item=TlenListGetItemPtrFromIndex(proto, i)) != NULL) { TLEN_FILE_TRANSFER *ft = item->ft; - JabberListRemoveByIndex(proto, i); + TlenListRemoveByIndex(proto, i); if (ft != NULL) { if (ft->s) { //ProtoBroadcastAck(m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - JabberLog(ft->proto, "Closing ft->s = %d", ft->s); + TlenLog(ft->proto, "Closing ft->s = %d", ft->s); ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); ft->s = NULL; @@ -451,7 +451,7 @@ int TlenFileCancelAll(TlenProtocol *proto) SetEvent(hEvent); } } else { - JabberLog(ft->proto, "freeing ft struct"); + TlenLog(ft->proto, "freeing ft struct"); TlenP2PFreeFileTransfer(ft); } } @@ -462,41 +462,41 @@ int TlenFileCancelAll(TlenProtocol *proto) static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) { - JABBER_SOCKET s = NULL; + TLEN_SOCKET s = NULL; HANDLE hEvent; char *nick; - JabberLog(ft->proto, "Thread started: type=tlen_file_send"); + TlenLog(ft->proto, "Thread started: type=tlen_file_send"); ft->mode = FT_SEND; ft->pfnNewConnectionV2 = TlenFileSendingConnection; s = TlenP2PListen(ft); if (s != NULL) { ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); ft->s = s; - //JabberLog("ft->s = %d", s); - //JabberLog("fileCount = %d", ft->fileCount); + //TlenLog("ft->s = %d", s); + //TlenLog("fileCount = %d", ft->fileCount); hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); ft->hFileEvent = hEvent; ft->currentFile = 0; ft->state = FT_CONNECTING; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - JabberLog(ft->proto, "Waiting for the file to be sent..."); + TlenLog(ft->proto, "Waiting for the file to be sent..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - JabberLog(ft->proto, "Finish all files"); + TlenLog(ft->proto, "Finish all files"); Netlib_CloseHandle(s); ft->s = NULL; - JabberLog(ft->proto, "ft->s is NULL"); + TlenLog(ft->proto, "ft->s is NULL"); if (ft->state == FT_SWITCH) { NETLIBOPENCONNECTION nloc; - JABBER_SOCKET s; - JabberLog(ft->proto, "Sending as client..."); + TLEN_SOCKET s; + TlenLog(ft->proto, "Sending as client..."); ft->state = FT_CONNECTING; nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = ft->hostName; @@ -507,7 +507,7 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); ft->s = s; TlenP2PEstablishOutgoingConnection(ft, TRUE); - JabberLog(ft->proto, "Entering send loop for this file connection..."); + TlenLog(ft->proto, "Entering send loop for this file connection..."); while (ft->state != FT_DONE && ft->state != FT_ERROR) { TlenFileSendParse(ft); } @@ -515,34 +515,34 @@ static void __cdecl TlenFileSendingThread(TLEN_FILE_TRANSFER *ft) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - JabberLog(ft->proto, "Closing connection for this file transfer... "); + TlenLog(ft->proto, "Closing connection for this file transfer... "); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; } } } else { - JabberLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); + TlenLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); ft->state = FT_ERROR; } - JabberListRemove(ft->proto, LIST_FILE, ft->iqId); + TlenListRemove(ft->proto, LIST_FILE, ft->iqId); switch (ft->state) { case FT_DONE: - JabberLog(ft->proto, "Finish successfully"); + TlenLog(ft->proto, "Finish successfully"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); break; case FT_DENIED: ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0); break; default: // FT_ERROR: - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); - JabberLog(ft->proto, "Finish with errors"); + TlenLog(ft->proto, "Finish with errors"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); break; } - JabberLog(ft->proto, "Thread ended: type=file_send"); + TlenLog(ft->proto, "Thread ended: type=file_send"); TlenP2PFreeFileTransfer(ft); } @@ -566,34 +566,34 @@ void TlenProcessF(XmlNode *node, ThreadData *info) char *from, *p, *e; char jid[128], szFilename[MAX_PATH]; int numFiles; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; // if (!node->name || strcmp(node->name, "f")) return; if (info == NULL) return; - if ((from=JabberXmlGetAttrValue(node, "f")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "f")) != NULL) { if (strchr(from, '@') == NULL) { mir_snprintf(jid, sizeof(jid), "%s@%s", from, info->server); } else { mir_snprintf(jid, sizeof(jid), "%s", from); } - if ((e=JabberXmlGetAttrValue(node, "e")) != NULL) { + if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) { if (!strcmp(e, "1")) { // FILE_RECV : e='1' : File transfer request ft = TlenFileCreateFT(info->proto, jid); - ft->hContact = JabberHContactFromJID(info->proto, jid); + ft->hContact = TlenHContactFromJID(info->proto, jid); - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) ft->iqId = mir_strdup(p); szFilename[0] = '\0'; - if ((p=JabberXmlGetAttrValue(node, "c")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "c")) != NULL) { numFiles = atoi(p); if (numFiles == 1) { - if ((p=JabberXmlGetAttrValue(node, "n")) != NULL) { - p = JabberTextDecode(p); + if ((p=TlenXmlGetAttrValue(node, "n")) != NULL) { + p = TlenTextDecode(p); strncpy(szFilename, p, sizeof(szFilename)); mir_free(p); } else { @@ -614,59 +614,59 @@ void TlenProcessF(XmlNode *node, ThreadData *info) pre.tszDescription = filenameT; pre.ptszFiles = &filenameT; pre.lParam = (LPARAM)ft; - JabberLog(ft->proto, "sending chainrecv"); + TlenLog(ft->proto, "sending chainrecv"); ProtoChainRecvFile(ft->hContact, &pre); mir_free(filenameT); } else { // malformed request, reject if (ft->iqId) - JabberSend(ft->proto, "", ft->iqId, from); + TlenSend(ft->proto, "", ft->iqId, from); else - JabberSend(ft->proto, "", from); + TlenSend(ft->proto, "", from); TlenP2PFreeFileTransfer(ft); } } else if (!strcmp(e, "3")) { // FILE_RECV : e='3' : invalid transfer error - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { if (item->ft != NULL) { ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, item->ft, 0); info->proto->FileCancel(NULL, item->ft); } - JabberListRemove(info->proto, LIST_FILE, p); + TlenListRemove(info->proto, LIST_FILE, p); } } } else if (!strcmp(e, "4")) { // FILE_SEND : e='4' : File sending request was denied by the remote client - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { if (!strcmp(item->ft->jid, jid)) { ProtoBroadcastAck(info->proto->m_szModuleName, item->ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, item->ft, 0); - JabberListRemove(info->proto, LIST_FILE, p); + TlenListRemove(info->proto, LIST_FILE, p); } } } } else if (!strcmp(e, "5")) { // FILE_SEND : e='5' : File sending request was accepted - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { if (!strcmp(item->ft->jid, jid)) - JabberForkThread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft); + TlenForkThread((void (__cdecl *)(void*))TlenFileSendingThread, 0, item->ft); } } } else if (!strcmp(e, "6")) { // FILE_RECV : e='6' : IP and port information to connect to get file - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { - if ((p=JabberXmlGetAttrValue(node, "a")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) { item->ft->hostName = mir_strdup(p); - if ((p=JabberXmlGetAttrValue(node, "p")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) { item->ft->wPort = atoi(p); - JabberForkThread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft); + TlenForkThread((void (__cdecl *)(void*))TlenFileReceiveThread, 0, item->ft); } } } @@ -675,12 +675,12 @@ void TlenProcessF(XmlNode *node, ThreadData *info) else if (!strcmp(e, "7")) { // FILE_RECV : e='7' : IP and port information to connect to send file // in case the conection to the given server was not successful - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { - if ((p=JabberXmlGetAttrValue(node, "a")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) { if (item->ft->hostName != NULL) mir_free(item->ft->hostName); item->ft->hostName = mir_strdup(p); - if ((p=JabberXmlGetAttrValue(node, "p")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) { item->ft->wPort = atoi(p); item->ft->state = FT_SWITCH; SetEvent(item->ft->hFileEvent); @@ -691,8 +691,8 @@ void TlenProcessF(XmlNode *node, ThreadData *info) } else if (!strcmp(e, "8")) { // FILE_RECV : e='8' : transfer error - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, p)) != NULL) { item->ft->state = FT_ERROR; if (item->ft->hFileEvent != NULL) { SetEvent(item->ft->hFileEvent); diff --git a/protocols/Tlen/src/tlen_iq.cpp b/protocols/Tlen/src/tlen_iq.cpp index 2b3431165e..1f2ec5a410 100644 --- a/protocols/Tlen/src/tlen_iq.cpp +++ b/protocols/Tlen/src/tlen_iq.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen_iq.h" -void JabberIqInit(TlenProtocol *proto) +void TlenIqInit(TlenProtocol *proto) { InitializeCriticalSection(&proto->csIqList); proto->iqList = NULL; @@ -32,7 +32,7 @@ void JabberIqInit(TlenProtocol *proto) proto->iqAlloced = 0; } -void JabberIqUninit(TlenProtocol *proto) +void TlenIqUninit(TlenProtocol *proto) { if (proto->iqList) mir_free(proto->iqList); proto->iqList = NULL; @@ -41,17 +41,17 @@ void JabberIqUninit(TlenProtocol *proto) DeleteCriticalSection(&proto->csIqList); } -static void JabberIqRemove(TlenProtocol *proto, int index) +static void TlenIqRemove(TlenProtocol *proto, int index) { EnterCriticalSection(&proto->csIqList); if (index >= 0 && indexiqCount) { - memmove(proto->iqList+index, proto->iqList+index+1, sizeof(JABBER_IQ_FUNC)*(proto->iqCount-index-1)); + memmove(proto->iqList+index, proto->iqList+index+1, sizeof(TLEN_IQ_FUNC)*(proto->iqCount-index-1)); proto->iqCount--; } LeaveCriticalSection(&proto->csIqList); } -static void JabberIqExpire(TlenProtocol *proto) +static void TlenIqExpire(TlenProtocol *proto) { int i; time_t expire; @@ -61,33 +61,33 @@ static void JabberIqExpire(TlenProtocol *proto) i = 0; while (i < proto->iqCount) { if (proto->iqList[i].requestTime < expire) - JabberIqRemove(proto, i); + TlenIqRemove(proto, i); else i++; } LeaveCriticalSection(&proto->csIqList); } -JABBER_IQ_PFUNC JabberIqFetchFunc(TlenProtocol *proto, int iqId) +TLEN_IQ_PFUNC TlenIqFetchFunc(TlenProtocol *proto, int iqId) { int i; - JABBER_IQ_PFUNC res; + TLEN_IQ_PFUNC res; EnterCriticalSection(&proto->csIqList); - JabberIqExpire(proto); + TlenIqExpire(proto); for (i=0; iiqCount && proto->iqList[i].iqId != iqId; i++); if (i < proto->iqCount) { res = proto->iqList[i].func; - JabberIqRemove(proto, i); + TlenIqRemove(proto, i); } else { - res = (JABBER_IQ_PFUNC) NULL; + res = (TLEN_IQ_PFUNC) NULL; } LeaveCriticalSection(&proto->csIqList); return res; } -void JabberIqAdd(TlenProtocol *proto, unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func) +void TlenIqAdd(TlenProtocol *proto, unsigned int iqId, TLEN_IQ_PROCID procId, TLEN_IQ_PFUNC func) { int i; @@ -99,7 +99,7 @@ void JabberIqAdd(TlenProtocol *proto, unsigned int iqId, JABBER_IQ_PROCID procId if (i >= proto->iqCount && proto->iqCount >= proto->iqAlloced) { proto->iqAlloced = proto->iqCount + 8; - proto->iqList = (JABBER_IQ_FUNC*)mir_realloc(proto->iqList, sizeof(JABBER_IQ_FUNC)*proto->iqAlloced); + proto->iqList = (TLEN_IQ_FUNC*)mir_realloc(proto->iqList, sizeof(TLEN_IQ_FUNC)*proto->iqAlloced); } if (proto->iqList != NULL) { diff --git a/protocols/Tlen/src/tlen_iq.h b/protocols/Tlen/src/tlen_iq.h index 35be984430..4cce89d95a 100644 --- a/protocols/Tlen/src/tlen_iq.h +++ b/protocols/Tlen/src/tlen_iq.h @@ -20,30 +20,30 @@ along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _JABBER_IQ_H_ -#define _JABBER_IQ_H_ +#ifndef _TLEN_IQ_H_ +#define _TLEN_IQ_H_ #include "tlen_xml.h" #include "tlen.h" -typedef void (*JABBER_IQ_PFUNC)(TlenProtocol *proto, XmlNode *iqNode); +typedef void (*TLEN_IQ_PFUNC)(TlenProtocol *proto, XmlNode *iqNode); -typedef struct JABBER_IQ_FUNC_STRUCT { +typedef struct TLEN_IQ_FUNC_STRUCT { int iqId; // id to match IQ get/set with IQ result - JABBER_IQ_PROCID procId; // must be unique in the list, except for IQ_PROC_NONE which can have multiple entries - JABBER_IQ_PFUNC func; // callback function + TLEN_IQ_PROCID procId; // must be unique in the list, except for IQ_PROC_NONE which can have multiple entries + TLEN_IQ_PFUNC func; // callback function time_t requestTime; // time the request was sent, used to remove relinquent entries -} JABBER_IQ_FUNC; +} TLEN_IQ_FUNC; -void JabberIqInit(TlenProtocol *proto); -void JabberIqUninit(TlenProtocol *proto); -JABBER_IQ_PFUNC JabberIqFetchFunc(TlenProtocol *proto, int iqId); -void JabberIqAdd(TlenProtocol *proto, unsigned int iqId, JABBER_IQ_PROCID procId, JABBER_IQ_PFUNC func); +void TlenIqInit(TlenProtocol *proto); +void TlenIqUninit(TlenProtocol *proto); +TLEN_IQ_PFUNC TlenIqFetchFunc(TlenProtocol *proto, int iqId); +void TlenIqAdd(TlenProtocol *proto, unsigned int iqId, TLEN_IQ_PROCID procId, TLEN_IQ_PFUNC func); -void JabberIqResultAuth(TlenProtocol *proto, XmlNode *iqNode); -void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode); +void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode); +void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode); -void JabberIqResultSearch(TlenProtocol *proto, XmlNode *iqNode); +void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode); @@ -55,7 +55,7 @@ void TlenIqResultUserNicks(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultRoomSearch(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultRoomInfo(TlenProtocol *proto, XmlNode *iqNode); void TlenIqResultChatRoomUsers(TlenProtocol *proto, XmlNode *iqNode); -//void JabberIqResultSetPassword(XmlNode *iqNode, void *userdata); +//void TlenIqResultSetPassword(XmlNode *iqNode, void *userdata); #endif diff --git a/protocols/Tlen/src/tlen_iqid.cpp b/protocols/Tlen/src/tlen_iqid.cpp index 87893e2fc5..3951902ea3 100644 --- a/protocols/Tlen/src/tlen_iqid.cpp +++ b/protocols/Tlen/src/tlen_iqid.cpp @@ -27,13 +27,13 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen_iq.h" #include "tlen_muc.h" -void JabberIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) +void TlenIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) { char *type; // RECVED: authentication result // ACTION: if successfully logged in, continue by requesting roster list and set my initial status - if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return; + if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; if (!strcmp(type, "result")) { DBVARIANT dbv; @@ -42,18 +42,18 @@ void JabberIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) db_set_s(NULL, proto->m_szModuleName, "Nick", proto->threadData->username); else db_free(&dbv); -// iqId = JabberSerialNext(); -// JabberIqAdd(iqId, IQ_PROC_NONE, JabberIqResultGetRoster); -// JabberSend(info, "", iqId); +// iqId = TlenSerialNext(); +// TlenIqAdd(iqId, IQ_PROC_NONE, TlenIqResultGetRoster); +// TlenSend(info, "", iqId); - JabberSend(proto, ""); - JabberSend(proto, ""); + TlenSend(proto, ""); + TlenSend(proto, ""); } // What to do if password error? etc... else if (!strcmp(type, "error")) { char text[128]; - JabberSend(proto, ""); + TlenSend(proto, ""); mir_snprintf(text, sizeof(text), "%s %s@%s.", TranslateT("Authentication failed for"), proto->threadData->username, proto->threadData->server); MessageBoxA(NULL, text, Translate("Tlen Authentication"), MB_OK|MB_ICONSTOP|MB_SETFOREGROUND); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_LOGIN, ACKRESULT_FAILED, NULL, LOGINERR_WRONGPASSWORD); @@ -61,10 +61,10 @@ void JabberIqResultAuth(TlenProtocol *proto, XmlNode *iqNode) } } -void JabberResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { +void TlenResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { DBVARIANT dbv; XmlNode *itemNode, *groupNode; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; HANDLE hContact; char *jid, *name, *nick; int i; @@ -73,41 +73,41 @@ void JabberResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { for (i=0; inumChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { - if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) { - str = JabberXmlGetAttrValue(itemNode, "subscription"); + if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { + str = TlenXmlGetAttrValue(itemNode, "subscription"); if (!strcmp(str, "remove")) { - if ((hContact=JabberHContactFromJID(proto, jid)) != NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) != NULL) { if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) db_set_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE); } - JabberListRemove(proto, LIST_ROSTER, jid); + TlenListRemove(proto, LIST_ROSTER, jid); } else { - item = JabberListAdd(proto, LIST_ROSTER, jid); + item = TlenListAdd(proto, LIST_ROSTER, jid); if (item != NULL) { if (str == NULL) item->subscription = SUB_NONE; else if (!strcmp(str, "both")) item->subscription = SUB_BOTH; else if (!strcmp(str, "to")) item->subscription = SUB_TO; else if (!strcmp(str, "from")) item->subscription = SUB_FROM; else item->subscription = SUB_NONE; - if ((name=JabberXmlGetAttrValue(itemNode, "name")) != NULL) { - nick = JabberTextDecode(name); + if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) { + nick = TlenTextDecode(name); } else { - nick = JabberLocalNickFromJID(jid); + nick = TlenLocalNickFromJID(jid); } if (nick != NULL) { if (item->nick) mir_free(item->nick); item->nick = nick; - if ((hContact=JabberHContactFromJID(proto, jid)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. - hContact = JabberDBCreateContact(proto, jid, nick, FALSE); + hContact = TlenDBCreateContact(proto, jid, nick, FALSE); } db_set_s(hContact, "CList", "MyHandle", nick); if (item->group) mir_free(item->group); - if ((groupNode=JabberXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { + if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); - JabberContactListCreateGroup(item->group); + TlenContactListCreateGroup(item->group); // Don't set group again if already correct, or Miranda may show wrong group count in some case if (!db_get(hContact, "CList", "Group", &dbv)) { if (strcmp(dbv.pszVal, item->group)) @@ -127,7 +127,7 @@ void JabberResultSetRoster(TlenProtocol *proto, XmlNode *queryNode) { } } -void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) +void TlenIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode; char *type; @@ -135,51 +135,51 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) // RECVED: roster information // ACTION: populate LIST_ROSTER and create contact for any new rosters - if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return; - if ((queryNode=JabberXmlGetChild(iqNode, "query")) == NULL) return; + if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; + if ((queryNode=TlenXmlGetChild(iqNode, "query")) == NULL) return; if (!strcmp(type, "result")) { - str = JabberXmlGetAttrValue(queryNode, "xmlns"); - if (str != NULL && !strcmp(str, "jabber:iq:roster")) { + str = TlenXmlGetAttrValue(queryNode, "xmlns"); + if (str != NULL && !strcmp(str, "tlen:iq:roster")) { DBVARIANT dbv; XmlNode *itemNode, *groupNode; - JABBER_SUBSCRIPTION sub; - JABBER_LIST_ITEM *item; + TLEN_SUBSCRIPTION sub; + TLEN_LIST_ITEM *item; char *jid, *name, *nick; int i, oldStatus; for (i=0; inumChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { - str = JabberXmlGetAttrValue(itemNode, "subscription"); + str = TlenXmlGetAttrValue(itemNode, "subscription"); if (str == NULL) sub = SUB_NONE; else if (!strcmp(str, "both")) sub = SUB_BOTH; else if (!strcmp(str, "to")) sub = SUB_TO; else if (!strcmp(str, "from")) sub = SUB_FROM; else sub = SUB_NONE; //if (str != NULL && (!strcmp(str, "to") || !strcmp(str, "both"))) { - if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) { - if ((name=JabberXmlGetAttrValue(itemNode, "name")) != NULL) - nick = JabberTextDecode(name); + if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { + if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) + nick = TlenTextDecode(name); else - nick = JabberLocalNickFromJID(jid); + nick = TlenLocalNickFromJID(jid); if (nick != NULL) { HANDLE hContact; - item = JabberListAdd(proto, LIST_ROSTER, jid); + item = TlenListAdd(proto, LIST_ROSTER, jid); if (item->nick) mir_free(item->nick); item->nick = nick; item->subscription = sub; - if ((hContact=JabberHContactFromJID(proto, jid)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. - hContact = JabberDBCreateContact(proto, jid, nick, FALSE); + hContact = TlenDBCreateContact(proto, jid, nick, FALSE); } db_set_s(hContact, "CList", "MyHandle", nick); if (item->group) mir_free(item->group); - if ((groupNode=JabberXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { + if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); - JabberContactListCreateGroup(item->group); + TlenContactListCreateGroup(item->group); // Don't set group again if already correct, or Miranda may show wrong group count in some case if (!db_get(hContact, "CList", "Group", &dbv)) { if (strcmp(dbv.pszVal, item->group)) @@ -195,7 +195,7 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) if (!db_get(hContact, proto->m_szModuleName, "AvatarHash", &dbv)) { if (item->avatarHash) mir_free(item->avatarHash); item->avatarHash = mir_strdup(dbv.pszVal); - JabberLog(proto, "Setting hash [%s] = %s", nick, item->avatarHash); + TlenLog(proto, "Setting hash [%s] = %s", nick, item->avatarHash); db_free(&dbv); } item->avatarFormat = db_get_dw(hContact, proto->m_szModuleName, "AvatarFormat", PA_FORMAT_UNKNOWN); @@ -210,8 +210,8 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) HANDLE hNext = hContact = db_find_next(hContact, proto->m_szModuleName); ptrA jid( db_get_sa(hContact, proto->m_szModuleName, "jid")); if (jid != NULL) { - if (!JabberListExist(proto, LIST_ROSTER, jid)) { - JabberLog(proto, "Syncing roster: deleting 0x%x", hContact); + if (!TlenListExist(proto, LIST_ROSTER, jid)) { + TlenLog(proto, "Syncing roster: deleting 0x%x", hContact); CallService(MS_DB_CONTACT_DELETE, (WPARAM)hContact, 0); } } @@ -226,16 +226,16 @@ void JabberIqResultRoster(TlenProtocol *proto, XmlNode *iqNode) Menu_ModifyItem(proto->hMenuChats, &mi); proto->isOnline = TRUE; - JabberLog(proto, "Status changed via THREADSTART"); + TlenLog(proto, "Status changed via THREADSTART"); oldStatus = proto->m_iStatus; - JabberSendPresence(proto, proto->m_iDesiredStatus); + TlenSendPresence(proto, proto->m_iDesiredStatus); ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); } } } -// Tlen actually use jabber:iq:search for other users vCard or jabber:iq:register for own vCard +// Tlen actually use tlen:iq:search for other users vCard or tlen:iq:register for own vCard void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode, *itemNode, *n; @@ -244,17 +244,17 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) HANDLE hContact; char *nText; -// JabberLog(" iqIdGetVcard (tlen)"); - if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return; +// TlenLog(" iqIdGetVcard (tlen)"); + if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; if (!strcmp(type, "result")) { BOOL hasFirst, hasLast, hasNick, hasEmail, hasCity, hasAge, hasGender, hasSchool, hasLookFor, hasOccupation; DBVARIANT dbv; int i; - if ((queryNode=JabberXmlGetChild(iqNode, "query")) == NULL) return; - if ((itemNode=JabberXmlGetChild(queryNode, "item")) == NULL) return; - if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) { + if ((queryNode=TlenXmlGetChild(iqNode, "query")) == NULL) return; + if ((itemNode=TlenXmlGetChild(queryNode, "item")) == NULL) return; + if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { if (db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) return; if (strchr(jid, '@') != NULL) { mir_snprintf(text, SIZEOF(text), "%s", jid); @@ -262,7 +262,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) mir_snprintf(text, SIZEOF(text), "%s@%s", jid, dbv.pszVal); // Add @tlen.pl } db_free(&dbv); - if ((hContact=JabberHContactFromJID(proto, text)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, text)) == NULL) { if (db_get(NULL, proto->m_szModuleName, "LoginName", &dbv)) return; if (strcmp(dbv.pszVal, jid)) { db_free(&dbv); @@ -280,7 +280,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) if (!strcmp(n->name, "first")) { if (n->text != NULL) { hasFirst = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "FirstName", nText); mir_free(nText); } @@ -288,7 +288,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!strcmp(n->name, "last")) { if (n->text != NULL) { hasLast = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "LastName", nText); mir_free(nText); } @@ -296,7 +296,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!strcmp(n->name, "nick")) { if (n->text != NULL) { hasNick = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "Nick", nText); mir_free(nText); } @@ -304,7 +304,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!strcmp(n->name, "email")) { if (n->text != NULL) { hasEmail = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "e-mail", nText); mir_free(nText); } @@ -312,7 +312,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!strcmp(n->name, "c")) { if (n->text != NULL) { hasCity = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "City", nText); mir_free(nText); } @@ -334,7 +334,7 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) else if (!strcmp(n->name, "e")) { if (n->text != NULL) { hasSchool = TRUE; - nText = JabberTextDecode(n->text); + nText = TlenTextDecode(n->text); db_set_s(hContact, proto->m_szModuleName, "School", nText); mir_free(nText); } @@ -395,29 +395,29 @@ void TlenIqResultVcard(TlenProtocol *proto, XmlNode *iqNode) } } -void JabberIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) +void TlenIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) { XmlNode *queryNode, *itemNode, *n; char *type, *jid, *str; int id, i, found; - JABBER_SEARCH_RESULT jsr = {0}; + TLEN_SEARCH_RESULT jsr = {0}; DBVARIANT dbv = {0}; found = 0; -// JabberLog(" iqIdGetSearch"); - if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return; - if ((str=JabberXmlGetAttrValue(iqNode, "id")) == NULL) return; - id = atoi(str+strlen(JABBER_IQID)); +// TlenLog(" iqIdGetSearch"); + if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; + if ((str=TlenXmlGetAttrValue(iqNode, "id")) == NULL) return; + id = atoi(str+strlen(TLEN_IQID)); if (!strcmp(type, "result")) { - if ((queryNode=JabberXmlGetChild(iqNode, "query")) == NULL) return; + if ((queryNode=TlenXmlGetChild(iqNode, "query")) == NULL) return; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { - jsr.hdr.cbSize = sizeof(JABBER_SEARCH_RESULT); + jsr.hdr.cbSize = sizeof(TLEN_SEARCH_RESULT); jsr.hdr.flags = PSR_TCHAR; for (i=0; inumChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { - if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) { + if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { if (strchr(jid, '@') != NULL) { mir_snprintf(jsr.jid, sizeof(jsr.jid), "%s", jid); } else { @@ -425,29 +425,29 @@ void JabberIqResultSearch(TlenProtocol *proto, XmlNode *iqNode) } jsr.jid[sizeof(jsr.jid)-1] = '\0'; jsr.hdr.id = mir_a2t(jid); - if ((n=JabberXmlGetChild(itemNode, "nick")) != NULL && n->text != NULL){ - char* buf = JabberTextDecode(n->text); + if ((n=TlenXmlGetChild(itemNode, "nick")) != NULL && n->text != NULL){ + char* buf = TlenTextDecode(n->text); jsr.hdr.nick = mir_a2t(buf); mir_free(buf); } else { jsr.hdr.nick = mir_tstrdup(TEXT("")); } - if ((n=JabberXmlGetChild(itemNode, "first")) != NULL && n->text != NULL){ - char* buf = JabberTextDecode(n->text); + if ((n=TlenXmlGetChild(itemNode, "first")) != NULL && n->text != NULL){ + char* buf = TlenTextDecode(n->text); jsr.hdr.firstName = mir_a2t(buf); mir_free(buf); } else { jsr.hdr.firstName = mir_tstrdup(TEXT("")); } - if ((n=JabberXmlGetChild(itemNode, "last")) != NULL && n->text != NULL){ - char* buf = JabberTextDecode(n->text); + if ((n=TlenXmlGetChild(itemNode, "last")) != NULL && n->text != NULL){ + char* buf = TlenTextDecode(n->text); jsr.hdr.lastName = mir_a2t(buf); mir_free(buf); } else { jsr.hdr.lastName = mir_tstrdup(TEXT("")); } - if ((n=JabberXmlGetChild(itemNode, "email"))!=NULL && n->text!=NULL){ - char* buf = JabberTextDecode(n->text); + if ((n=TlenXmlGetChild(itemNode, "email"))!=NULL && n->text!=NULL){ + char* buf = TlenTextDecode(n->text); jsr.hdr.email = mir_a2t(buf); mir_free(buf); } else { @@ -508,7 +508,7 @@ void GetConfigItem(XmlNode *node, char *dest, BOOL bMethod, int *methodDest) { strcpy(dest, node->text); TlenUrlDecode(dest); if (bMethod) { - char *method = JabberXmlGetAttrValue(node, "method"); + char *method = TlenXmlGetAttrValue(node, "method"); if (method != NULL && !strcmpi(method, "POST")) { *methodDest = REQUEST_POST; } else { @@ -522,32 +522,32 @@ void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode) XmlNode *queryNode, *miniMailNode, *node; char *type; - if ((type=JabberXmlGetAttrValue(iqNode, "type")) == NULL) return; + if ((type=TlenXmlGetAttrValue(iqNode, "type")) == NULL) return; if (!strcmp(type, "result")) { - if ((queryNode=JabberXmlGetChild(iqNode, "query")) == NULL) return; - if ((miniMailNode=JabberXmlGetChild(queryNode, "mini-mail")) == NULL) return; - if ((node=JabberXmlGetChild(miniMailNode, "base")) != NULL) { + if ((queryNode=TlenXmlGetChild(iqNode, "query")) == NULL) return; + if ((miniMailNode=TlenXmlGetChild(queryNode, "mini-mail")) == NULL) return; + if ((node=TlenXmlGetChild(miniMailNode, "base")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailBase, FALSE, NULL); } - if ((node=JabberXmlGetChild(miniMailNode, "msg")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "msg")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailMsg, TRUE, &proto->threadData->tlenConfig.mailMsgMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "index")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "index")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailIndex, TRUE, &proto->threadData->tlenConfig.mailIndexMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "login")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "login")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailLogin, TRUE, &proto->threadData->tlenConfig.mailLoginMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "compose")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "compose")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.mailCompose, TRUE, &proto->threadData->tlenConfig.mailComposeMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "avatar-get")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "avatar-get")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarGet, TRUE, &proto->threadData->tlenConfig.avatarGetMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "avatar-upload")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "avatar-upload")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarUpload, TRUE, &proto->threadData->tlenConfig.avatarUploadMthd); } - if ((node=JabberXmlGetChild(miniMailNode, "avatar-remove")) != NULL) { + if ((node=TlenXmlGetChild(miniMailNode, "avatar-remove")) != NULL) { GetConfigItem(node, proto->threadData->tlenConfig.avatarRemove, TRUE, &proto->threadData->tlenConfig.avatarRemoveMthd); } } @@ -555,30 +555,30 @@ void TlenIqResultTcfg(TlenProtocol *proto, XmlNode *iqNode) void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode) { - XmlNode *queryNode = JabberXmlGetChild(iqNode, "query"); + XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode != NULL) { char* from; - if (( from=JabberXmlGetAttrValue( iqNode, "from" )) != NULL ) { - JABBER_LIST_ITEM *item; - if (( item=JabberListGetItemPtr( proto, LIST_ROSTER, from )) != NULL) { + if (( from=TlenXmlGetAttrValue( iqNode, "from" )) != NULL ) { + TLEN_LIST_ITEM *item; + if (( item=TlenListGetItemPtr( proto, LIST_ROSTER, from )) != NULL) { HANDLE hContact; XmlNode *n; if ( item->software ) mir_free( item->software ); if ( item->version ) mir_free( item->version ); if ( item->system ) mir_free( item->system ); - if (( n=JabberXmlGetChild( queryNode, "name" )) != NULL && n->text ) { - item->software = JabberTextDecode( n->text ); + if (( n=TlenXmlGetChild( queryNode, "name" )) != NULL && n->text ) { + item->software = TlenTextDecode( n->text ); } else item->software = NULL; - if (( n=JabberXmlGetChild( queryNode, "version" )) != NULL && n->text ) - item->version = JabberTextDecode( n->text ); + if (( n=TlenXmlGetChild( queryNode, "version" )) != NULL && n->text ) + item->version = TlenTextDecode( n->text ); else item->version = NULL; - if (( n=JabberXmlGetChild( queryNode, "os" )) != NULL && n->text ) - item->system = JabberTextDecode( n->text ); + if (( n=TlenXmlGetChild( queryNode, "os" )) != NULL && n->text ) + item->system = TlenTextDecode( n->text ); else item->system = NULL; - if (( hContact=JabberHContactFromJID(proto, item->jid )) != NULL ) { + if (( hContact=TlenHContactFromJID(proto, item->jid )) != NULL ) { if (item->software != NULL) { db_set_s(hContact, proto->m_szModuleName, "MirVer", item->software); } else { @@ -592,16 +592,16 @@ void TlenIqResultVersion(TlenProtocol *proto, XmlNode *iqNode) void TlenIqResultInfo(TlenProtocol *proto, XmlNode *iqNode) { - XmlNode *queryNode = JabberXmlGetChild(iqNode, "query"); + XmlNode *queryNode = TlenXmlGetChild(iqNode, "query"); if (queryNode != NULL) { char* from; - if (( from=JabberXmlGetAttrValue( queryNode, "from" )) != NULL ) { - JABBER_LIST_ITEM *item; - if (( item=JabberListGetItemPtr( proto, LIST_ROSTER, from )) != NULL) { + if (( from=TlenXmlGetAttrValue( queryNode, "from" )) != NULL ) { + TLEN_LIST_ITEM *item; + if (( item=TlenListGetItemPtr( proto, LIST_ROSTER, from )) != NULL) { HANDLE hContact; - XmlNode *version = JabberXmlGetChild(queryNode, "version"); - item->protocolVersion = JabberTextDecode(version->text); - if (( hContact=JabberHContactFromJID(proto, item->jid )) != NULL ) { + XmlNode *version = TlenXmlGetChild(queryNode, "version"); + item->protocolVersion = TlenTextDecode(version->text); + if (( hContact=TlenHContactFromJID(proto, item->jid )) != NULL ) { if (item->software == NULL) { char str[128]; mir_snprintf(str, sizeof(str), "Tlen Protocol %s", item->protocolVersion); diff --git a/protocols/Tlen/src/tlen_list.cpp b/protocols/Tlen/src/tlen_list.cpp index 7010a8e101..ee6b5820da 100644 --- a/protocols/Tlen/src/tlen_list.cpp +++ b/protocols/Tlen/src/tlen_list.cpp @@ -25,28 +25,28 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen_list.h" -static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item); +static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item); -void JabberListInit(TlenProtocol *proto) +void TlenListInit(TlenProtocol *proto) { proto->lists = NULL; proto->listsCount = 0; InitializeCriticalSection(&proto->csLists); } -void JabberListUninit(TlenProtocol *proto) +void TlenListUninit(TlenProtocol *proto) { - JabberListWipe(proto); + TlenListWipe(proto); DeleteCriticalSection(&proto->csLists); } -void JabberListWipe(TlenProtocol *proto) +void TlenListWipe(TlenProtocol *proto) { int i; EnterCriticalSection(&proto->csLists); for (i=0; ilistsCount; i++) - JabberListFreeItemInternal(&(proto->lists[i])); + TlenListFreeItemInternal(&(proto->lists[i])); if (proto->lists != NULL) { mir_free(proto->lists); proto->lists = NULL; @@ -55,23 +55,23 @@ void JabberListWipe(TlenProtocol *proto) LeaveCriticalSection(&proto->csLists); } -void JabberListWipeSpecial(TlenProtocol *proto) +void TlenListWipeSpecial(TlenProtocol *proto) { int i; EnterCriticalSection(&proto->csLists); for (i=0; ilistsCount; i++) { if (proto->lists[i].list != LIST_FILE && proto->lists[i].list != LIST_VOICE) { - JabberListFreeItemInternal(&(proto->lists[i])); + TlenListFreeItemInternal(&(proto->lists[i])); proto->listsCount--; - memmove(proto->lists+i, proto->lists+i+1, sizeof(JABBER_LIST_ITEM)*(proto->listsCount-i)); + memmove(proto->lists+i, proto->lists+i+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-i)); i--; } } - proto->lists = (JABBER_LIST_ITEM *) mir_realloc(proto->lists, sizeof(JABBER_LIST_ITEM)*proto->listsCount); + proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount); LeaveCriticalSection(&proto->csLists); } -static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) +static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item) { if (item == NULL) return; @@ -82,7 +82,7 @@ static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) if (item->group) mir_free(item->group); if (item->messageEventIdStr) mir_free(item->messageEventIdStr); // if (item->type) mir_free(item->type); - //if (item->ft) JabberFileFreeFt(item->ft); // No need to free (it is always free when exit from JabberFileServerThread()) + //if (item->ft) TlenFileFreeFt(item->ft); // No need to free (it is always free when exit from TlenFileServerThread()) if (item->roomName) mir_free(item->roomName); if (item->version) mir_free(item->version); if (item->software) mir_free(item->software); @@ -93,7 +93,7 @@ static void JabberListFreeItemInternal(JABBER_LIST_ITEM *item) if (item->id2) mir_free(item->id2); } -static char * GetItemId(JABBER_LIST list, const char *jid) +static char * GetItemId(TLEN_LIST list, const char *jid) { char *s, *p, *q; s = mir_strdup(jid); @@ -109,7 +109,7 @@ static char * GetItemId(JABBER_LIST list, const char *jid) } -int JabberListExist(TlenProtocol *proto, JABBER_LIST list, const char *jid) +int TlenListExist(TlenProtocol *proto, TLEN_LIST list, const char *jid) { int i; size_t len; @@ -132,21 +132,21 @@ int JabberListExist(TlenProtocol *proto, JABBER_LIST list, const char *jid) return 0; } -JABBER_LIST_ITEM *JabberListAdd(TlenProtocol *proto, JABBER_LIST list, const char *jid) +TLEN_LIST_ITEM *TlenListAdd(TlenProtocol *proto, TLEN_LIST list, const char *jid) { char *s; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; EnterCriticalSection(&proto->csLists); - if ((item=JabberListGetItemPtr(proto, list, jid)) != NULL) { + if ((item=TlenListGetItemPtr(proto, list, jid)) != NULL) { LeaveCriticalSection(&proto->csLists); return item; } s = GetItemId(list, jid); - proto->lists = (JABBER_LIST_ITEM *) mir_realloc(proto->lists, sizeof(JABBER_LIST_ITEM)*(proto->listsCount+1)); + proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*(proto->listsCount+1)); item = &(proto->lists[proto->listsCount]); - memset(item, 0, sizeof(JABBER_LIST_ITEM)); + memset(item, 0, sizeof(TLEN_LIST_ITEM)); item->list = list; item->jid = s; item->nick = NULL; @@ -173,52 +173,52 @@ JABBER_LIST_ITEM *JabberListAdd(TlenProtocol *proto, JABBER_LIST list, const cha return item; } -void JabberListRemove(TlenProtocol *proto, JABBER_LIST list, const char *jid) +void TlenListRemove(TlenProtocol *proto, TLEN_LIST list, const char *jid) { int i; EnterCriticalSection(&proto->csLists); - i = JabberListExist(proto, list, jid); + i = TlenListExist(proto, list, jid); if (!i) { LeaveCriticalSection(&proto->csLists); return; } i--; - JabberListFreeItemInternal(&(proto->lists[i])); + TlenListFreeItemInternal(&(proto->lists[i])); proto->listsCount--; - memmove(proto->lists+i, proto->lists+i+1, sizeof(JABBER_LIST_ITEM)*(proto->listsCount-i)); - proto->lists = (JABBER_LIST_ITEM *) mir_realloc(proto->lists, sizeof(JABBER_LIST_ITEM)*proto->listsCount); + memmove(proto->lists+i, proto->lists+i+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-i)); + proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount); LeaveCriticalSection(&proto->csLists); } -void JabberListRemoveList(TlenProtocol *proto, JABBER_LIST list) +void TlenListRemoveList(TlenProtocol *proto, TLEN_LIST list) { int i; i = 0; - while ((i=JabberListFindNext(proto, list, i)) >= 0) { - JabberListRemoveByIndex(proto, i); + while ((i=TlenListFindNext(proto, list, i)) >= 0) { + TlenListRemoveByIndex(proto, i); } } -void JabberListRemoveByIndex(TlenProtocol *proto, int index) +void TlenListRemoveByIndex(TlenProtocol *proto, int index) { EnterCriticalSection(&proto->csLists); if (index >= 0 && indexlistsCount) { - JabberListFreeItemInternal(&(proto->lists[index])); + TlenListFreeItemInternal(&(proto->lists[index])); proto->listsCount--; - memmove(proto->lists+index, proto->lists+index+1, sizeof(JABBER_LIST_ITEM)*(proto->listsCount-index)); - proto->lists = (JABBER_LIST_ITEM *) mir_realloc(proto->lists, sizeof(JABBER_LIST_ITEM)*proto->listsCount); + memmove(proto->lists+index, proto->lists+index+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-index)); + proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount); } LeaveCriticalSection(&proto->csLists); } -void JabberListAddResource(TlenProtocol *proto, JABBER_LIST list, const char *jid, int status, const char *statusMessage) +void TlenListAddResource(TlenProtocol *proto, TLEN_LIST list, const char *jid, int status, const char *statusMessage) { int i; EnterCriticalSection(&proto->csLists); - i = JabberListExist(proto, list, jid); + i = TlenListExist(proto, list, jid); if (!i) { LeaveCriticalSection(&proto->csLists); return; @@ -234,11 +234,11 @@ void JabberListAddResource(TlenProtocol *proto, JABBER_LIST list, const char *ji LeaveCriticalSection(&proto->csLists); } -void JabberListRemoveResource(TlenProtocol *proto, JABBER_LIST list, const char *jid) +void TlenListRemoveResource(TlenProtocol *proto, TLEN_LIST list, const char *jid) { int i; EnterCriticalSection(&proto->csLists); - i = JabberListExist(proto, list, jid); + i = TlenListExist(proto, list, jid); if (!i) { LeaveCriticalSection(&proto->csLists); return; @@ -247,7 +247,7 @@ void JabberListRemoveResource(TlenProtocol *proto, JABBER_LIST list, const char LeaveCriticalSection(&proto->csLists); } -int JabberListFindNext(TlenProtocol *proto, JABBER_LIST list, int fromOffset) +int TlenListFindNext(TlenProtocol *proto, TLEN_LIST list, int fromOffset) { int i; @@ -262,12 +262,12 @@ int JabberListFindNext(TlenProtocol *proto, JABBER_LIST list, int fromOffset) return -1; } -JABBER_LIST_ITEM *JabberListGetItemPtr(TlenProtocol *proto, JABBER_LIST list, const char *jid) +TLEN_LIST_ITEM *TlenListGetItemPtr(TlenProtocol *proto, TLEN_LIST list, const char *jid) { int i; EnterCriticalSection(&proto->csLists); - i = JabberListExist(proto, list, jid); + i = TlenListExist(proto, list, jid); if (!i) { LeaveCriticalSection(&proto->csLists); return NULL; @@ -277,7 +277,7 @@ JABBER_LIST_ITEM *JabberListGetItemPtr(TlenProtocol *proto, JABBER_LIST list, co return &(proto->lists[i]); } -JABBER_LIST_ITEM *JabberListFindItemPtrById2(TlenProtocol *proto, JABBER_LIST list, const char *id) +TLEN_LIST_ITEM *TlenListFindItemPtrById2(TlenProtocol *proto, TLEN_LIST list, const char *id) { int i; @@ -302,7 +302,7 @@ JABBER_LIST_ITEM *JabberListFindItemPtrById2(TlenProtocol *proto, JABBER_LIST li return NULL; } -JABBER_LIST_ITEM *JabberListGetItemPtrFromIndex(TlenProtocol *proto, int index) +TLEN_LIST_ITEM *TlenListGetItemPtrFromIndex(TlenProtocol *proto, int index) { EnterCriticalSection(&proto->csLists); if (index >= 0 && indexlistsCount) { diff --git a/protocols/Tlen/src/tlen_list.h b/protocols/Tlen/src/tlen_list.h index 80b294e459..680190672a 100644 --- a/protocols/Tlen/src/tlen_list.h +++ b/protocols/Tlen/src/tlen_list.h @@ -23,11 +23,11 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen.h" -#ifndef _JABBER_LIST_H_ -#define _JABBER_LIST_H_ +#ifndef _TLEN_LIST_H_ +#define _TLEN_LIST_H_ -typedef struct JABBER_LIST_ITEM_STRUCT { - JABBER_LIST list; +typedef struct TLEN_LIST_ITEM_STRUCT { + TLEN_LIST list; char *jid; char *id2; @@ -36,7 +36,7 @@ typedef struct JABBER_LIST_ITEM_STRUCT { char *nick; int status; // Main status, currently useful for transport where no resource information is kept. // On normal contact, this is the same status as shown on contact list. - JABBER_SUBSCRIPTION subscription; + TLEN_SUBSCRIPTION subscription; char *statusMessage; // Status message when the update is to JID with no resource specified (e.g. transport user) char *software; char *version; @@ -61,30 +61,30 @@ typedef struct JABBER_LIST_ITEM_STRUCT { // LIST_CHATROOM // jid = room JID // char *nick; // my nick in this chat room (SPECIAL: in UTF8) - // JABBER_RESOURCE_STATUS *resource; // participant nicks in this room + // TLEN_RESOURCE_STATUS *resource; // participant nicks in this room char *roomName; // LIST_FILE struct TLEN_FILE_TRANSFER_STRUCT *ft; -} JABBER_LIST_ITEM; - - -void JabberListInit(TlenProtocol *proto); -void JabberListUninit(TlenProtocol *proto); -void JabberListWipe(TlenProtocol *proto); -void JabberListWipeSpecial(TlenProtocol *proto); -int JabberListExist(TlenProtocol *proto, JABBER_LIST list, const char *jid); -JABBER_LIST_ITEM *JabberListAdd(TlenProtocol *proto, JABBER_LIST list, const char *jid); -void JabberListRemove(TlenProtocol *proto, JABBER_LIST list, const char *jid); -void JabberListRemoveList(TlenProtocol *proto, JABBER_LIST list); -void JabberListRemoveByIndex(TlenProtocol *proto, int index); -int JabberListFindNext(TlenProtocol *proto, JABBER_LIST list, int fromOffset); -JABBER_LIST_ITEM *JabberListGetItemPtr(TlenProtocol *proto, JABBER_LIST list, const char *jid); -JABBER_LIST_ITEM *JabberListGetItemPtrFromIndex(TlenProtocol *proto, int index); -JABBER_LIST_ITEM *JabberListFindItemPtrById2(TlenProtocol *proto, JABBER_LIST list, const char *id); - -void JabberListAddResource(TlenProtocol *proto, JABBER_LIST list, const char *jid, int status, const char *statusMessage); -void JabberListRemoveResource(TlenProtocol *proto, JABBER_LIST list, const char *jid); +} TLEN_LIST_ITEM; + + +void TlenListInit(TlenProtocol *proto); +void TlenListUninit(TlenProtocol *proto); +void TlenListWipe(TlenProtocol *proto); +void TlenListWipeSpecial(TlenProtocol *proto); +int TlenListExist(TlenProtocol *proto, TLEN_LIST list, const char *jid); +TLEN_LIST_ITEM *TlenListAdd(TlenProtocol *proto, TLEN_LIST list, const char *jid); +void TlenListRemove(TlenProtocol *proto, TLEN_LIST list, const char *jid); +void TlenListRemoveList(TlenProtocol *proto, TLEN_LIST list); +void TlenListRemoveByIndex(TlenProtocol *proto, int index); +int TlenListFindNext(TlenProtocol *proto, TLEN_LIST list, int fromOffset); +TLEN_LIST_ITEM *TlenListGetItemPtr(TlenProtocol *proto, TLEN_LIST list, const char *jid); +TLEN_LIST_ITEM *TlenListGetItemPtrFromIndex(TlenProtocol *proto, int index); +TLEN_LIST_ITEM *TlenListFindItemPtrById2(TlenProtocol *proto, TLEN_LIST list, const char *id); + +void TlenListAddResource(TlenProtocol *proto, TLEN_LIST list, const char *jid, int status, const char *statusMessage); +void TlenListRemoveResource(TlenProtocol *proto, TLEN_LIST list, const char *jid); #endif diff --git a/protocols/Tlen/src/tlen_misc.cpp b/protocols/Tlen/src/tlen_misc.cpp index f90bf62509..4c05d5e566 100644 --- a/protocols/Tlen/src/tlen_misc.cpp +++ b/protocols/Tlen/src/tlen_misc.cpp @@ -24,7 +24,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen.h" #include "tlen_list.h" -void JabberDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob) +void TlenDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD flags, PBYTE pBlob, DWORD cbBlob) { DBEVENTINFO dbei = { sizeof(dbei) }; dbei.szModule = proto->m_szModuleName; @@ -36,7 +36,7 @@ void JabberDBAddEvent(TlenProtocol *proto, HANDLE hContact, int eventType, DWORD db_event_add(hContact, &dbei); } -void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) +void TlenDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) { char *s; PBYTE pCurBlob; @@ -44,11 +44,11 @@ void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) DWORD cbBlob; HANDLE hContact; - if ((hContact=JabberHContactFromJID(proto, jid)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) proto->m_szModuleName); // strip resource if present - s = JabberLoginFromJID(jid); + s = TlenLoginFromJID(jid); _strlwr(s); db_set_s(hContact, proto->m_szModuleName, "jid", s); mir_free(s); @@ -57,7 +57,7 @@ void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) db_unset(hContact, proto->m_szModuleName, "Hidden"); } db_set_s(hContact, proto->m_szModuleName, "Nick", nick); - JabberLog(proto, "auth request: %s, %s", jid, nick); + TlenLog(proto, "auth request: %s, %s", jid, nick); //blob is: uin(DWORD), hContact(HANDLE), nick(ASCIIZ), first(ASCIIZ), last(ASCIIZ), email(ASCIIZ), reason(ASCIIZ) //blob is: 0(DWORD), hContact(HANDLE), nick(ASCIIZ), ""(ASCIIZ), ""(ASCIIZ), email(ASCIIZ), ""(ASCIIZ) cbBlob = sizeof(DWORD) + sizeof(HANDLE) + (int)strlen(nick) + (int)strlen(jid) + 5; @@ -69,10 +69,10 @@ void JabberDBAddAuthRequest(TlenProtocol *proto, char *jid, char *nick) *pCurBlob = '\0'; pCurBlob++; //lastName strcpy((char *) pCurBlob, jid); pCurBlob += strlen(jid)+1; *pCurBlob = '\0'; //reason - JabberDBAddEvent(proto, NULL, EVENTTYPE_AUTHREQUEST, 0, pBlob, cbBlob); + TlenDBAddEvent(proto, NULL, EVENTTYPE_AUTHREQUEST, 0, pBlob, cbBlob); } -char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact) +char *TlenJIDFromHContact(TlenProtocol *proto, HANDLE hContact) { char *p = NULL; DBVARIANT dbv; @@ -83,7 +83,7 @@ char *JabberJIDFromHContact(TlenProtocol *proto, HANDLE hContact) return p; } -HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid) +HANDLE TlenHContactFromJID(TlenProtocol *proto, const char *jid) { DBVARIANT dbv; char *p; @@ -106,13 +106,13 @@ HANDLE JabberHContactFromJID(TlenProtocol *proto, const char *jid) return NULL; } -HANDLE JabberDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary) +HANDLE TlenDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL temporary) { HANDLE hContact; if (jid == NULL || jid[0] == '\0') return NULL; - if ((hContact=JabberHContactFromJID(proto, jid)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) == NULL) { hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) proto->m_szModuleName); db_set_s(hContact, proto->m_szModuleName, "jid", jid); @@ -124,7 +124,7 @@ HANDLE JabberDBCreateContact(TlenProtocol *proto, char *jid, char *nick, BOOL te return hContact; } -static void JabberContactListCreateClistGroup(char *groupName) +static void TlenContactListCreateClistGroup(char *groupName) { char str[33], newName[128]; int i; @@ -152,7 +152,7 @@ static void JabberContactListCreateClistGroup(char *groupName) CallService(MS_CLUI_GROUPADDED, i+1, 0); } -void JabberContactListCreateGroup(char *groupName) +void TlenContactListCreateGroup(char *groupName) { char name[128]; char *p; @@ -164,11 +164,11 @@ void JabberContactListCreateGroup(char *groupName) for (p=name; *p != '\0'; p++) { if (*p == '\\') { *p = '\0'; - JabberContactListCreateClistGroup(name); + TlenContactListCreateClistGroup(name); *p = '\\'; } } - JabberContactListCreateClistGroup(name); + TlenContactListCreateClistGroup(name); } @@ -189,7 +189,7 @@ static void __cdecl forkthread_r(struct FORK_ARG *fa) return; } -unsigned long JabberForkThread( +unsigned long TlenForkThread( void (__cdecl *threadcode)(void*), unsigned long stacksize, void *arg diff --git a/protocols/Tlen/src/tlen_muc.cpp b/protocols/Tlen/src/tlen_muc.cpp index 393a19be27..a62601b760 100644 --- a/protocols/Tlen/src/tlen_muc.cpp +++ b/protocols/Tlen/src/tlen_muc.cpp @@ -35,10 +35,10 @@ static int TlenMUCSendQuery(TlenProtocol *proto, int type, const char *parent, i static int isSelf(TlenProtocol *proto, const char *roomID, const char *nick) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; int result; result=0; - item = JabberListGetItemPtr(proto, LIST_CHATROOM, roomID); + item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID); if (item != NULL) { if (item->nick == NULL) { if (!strcmp(nick, proto->threadData->username)) result = 1; @@ -74,7 +74,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { mir_snprintf(jid, sizeof(jid), "%s@%s", id, dbv.pszVal); db_free(&dbv); - if (((hContact=JabberHContactFromJID(proto, jid)) != NULL) || !strcmp(id, proto->threadData->username)) { + if (((hContact=TlenHContactFromJID(proto, jid)) != NULL) || !strcmp(id, proto->threadData->username)) { CONTACTINFO ci = { sizeof(ci) }; ci.hContact = hContact; ci.szProto = (char *)proto->m_szModuleName; @@ -156,28 +156,28 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) TlenMUCSendQuery(this, 6, mucce->pszNick, 1); break; case MUCC_EVENT_REGISTER_ROOM: - id = JabberSerialNext(this); + id = TlenSerialNext(this); if (isOnline) { if (mucce->pszNick != NULL) - JabberSend(this, "

", id, mucce->dwFlags | 0x10, mucce->pszName, mucce->pszID); + TlenSend(this, "

", id, mucce->dwFlags | 0x10, mucce->pszName, mucce->pszID); else - JabberSend(this, "

", id, mucce->dwFlags | 0x10, mucce->pszName, mucce->pszID); + TlenSend(this, "

", id, mucce->dwFlags | 0x10, mucce->pszName, mucce->pszID); } break; case MUCC_EVENT_REMOVE_ROOM: if (isOnline) { - JabberSend(this, "

", mucce->pszID); - JabberListRemove(this, LIST_CHATROOM, mucce->pszID); + TlenSend(this, "

", mucce->pszID); + TlenListRemove(this, LIST_CHATROOM, mucce->pszID); // TlenMUCSendPresence(mucce->pszID, NULL, ID_STATUS_OFFLINE); } break; case MUCC_EVENT_KICK_BAN: if (isOnline) { char *nick; - nick = JabberResourceFromJID(mucce->pszUID); + nick = TlenResourceFromJID(mucce->pszUID); if (!isSelf(this, mucce->pszID, nick)) { - char *reason = JabberTextEncode(mucce->pszText); - JabberSend(this, "

", mucce->pszID, nick, mucce->dwData, reason); + char *reason = TlenTextEncode(mucce->pszText); + TlenSend(this, "

", mucce->pszID, nick, mucce->dwData, reason); mir_free(reason); } mir_free(nick); @@ -186,9 +186,9 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) case MUCC_EVENT_UNBAN: if (isOnline) { char *nick; - nick = JabberResourceFromJID(mucce->pszUID); + nick = TlenResourceFromJID(mucce->pszUID); if (!isSelf(this, mucce->pszID, nick)) { - JabberSend(this, "

", mucce->pszID, nick); + TlenSend(this, "

", mucce->pszID, nick); } mir_free(nick); } @@ -196,7 +196,7 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) case MUCC_EVENT_SET_USER_ROLE: if (isOnline) { char *nick; - nick = JabberResourceFromJID(mucce->pszUID); + nick = TlenResourceFromJID(mucce->pszUID); if (!isSelf(this, mucce->pszID, nick)) { if (mucce->dwFlags == MUCC_EF_USER_ADMIN) { id = 2; @@ -205,7 +205,7 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) } else { id = 0; } - JabberSend(this, "

", mucce->pszID, nick, id); + TlenSend(this, "

", mucce->pszID, nick, id); } mir_free(nick); } @@ -223,8 +223,8 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) if (isOnline) { if (mucce->pszID == NULL || strlen(mucce->pszID) == 0) { if (mucce->pszName == NULL || strlen(mucce->pszName) == 0) { // create a new chat room - id = JabberSerialNext(this); - JabberSend(this, "

", id); + id = TlenSerialNext(this); + TlenSend(this, "

", id); } else TlenMUCSendQuery(this, 3, mucce->pszName, 0); // find a chat room by name } @@ -235,14 +235,14 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) break; case MUCC_EVENT_START_PRIV: if (isOnline) { - JABBER_LIST_ITEM *item = JabberListGetItemPtr(this, LIST_CHATROOM, mucce->pszID); + TLEN_LIST_ITEM *item = TlenListGetItemPtr(this, LIST_CHATROOM, mucce->pszID); if (item != NULL) { - char *nick = JabberResourceFromJID(mucce->pszUID); + char *nick = TlenResourceFromJID(mucce->pszUID); if (!isSelf(this, mucce->pszID, nick)) { if (nick[0] == '~' || item->nick != NULL) { char str[256]; mir_snprintf(str, SIZEOF(str), "%s/%s", mucce->pszID, nick); - hContact = JabberDBCreateContact(this, str, nick, TRUE); //(char *)mucce->pszUID + hContact = TlenDBCreateContact(this, str, nick, TRUE); //(char *)mucce->pszUID db_set_b(hContact, m_szModuleName, "bChat", TRUE); CallService(MS_MSG_SENDMESSAGE, (WPARAM) hContact, (LPARAM) NULL); } @@ -252,7 +252,7 @@ int TlenProtocol::MUCHandleEvent(WPARAM wParam, LPARAM lParam) char str[512]; mir_snprintf(str, sizeof(str), "%s@%s", nick, dbv.pszVal); db_free(&dbv); - hContact = JabberDBCreateContact(this, str, nick, TRUE); + hContact = TlenDBCreateContact(this, str, nick, TRUE); CallService(MS_MSG_SENDMESSAGE, (WPARAM) hContact, (LPARAM) NULL); } } @@ -292,7 +292,7 @@ int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char *r ask = TRUE; } else if (groupChatPolicy == TLEN_MUC_ACCEPT_IR) { char jid[256]; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; DBVARIANT dbv; if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { mir_snprintf(jid, sizeof(jid), "%s@%s", from, dbv.pszVal); @@ -300,7 +300,7 @@ int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char *r } else { strcpy(jid, from); } - item = JabberListGetItemPtr(proto, LIST_ROSTER, jid); + item = TlenListGetItemPtr(proto, LIST_ROSTER, jid); ask = !IsAuthorized(proto, jid); ignore = FALSE; } else if (groupChatPolicy == TLEN_MUC_ACCEPT_ALL) { @@ -333,11 +333,11 @@ int TlenMUCRecvInvitation(TlenProtocol *proto, const char *roomId, const char *r int TlenMUCRecvPresence(TlenProtocol *proto, const char *from, int status, int flags, const char *kick) { char str[512]; -// if (JabberListExist(LIST_CHATROOM, from)) { +// if (TlenListExist(LIST_CHATROOM, from)) { char *nick, *roomId, *userId; MUCCEVENT mucce; - roomId = JabberLoginFromJID(from); - userId = JabberResourceFromJID(from); + roomId = TlenLoginFromJID(from); + userId = TlenResourceFromJID(from); nick = getDisplayName(proto, userId); mucce.cbSize = sizeof(MUCCEVENT); mucce.pszModule = proto->m_szModuleName; @@ -368,15 +368,15 @@ int TlenMUCRecvPresence(TlenProtocol *proto, const char *from, int status, int f int TlenMUCRecvMessage(TlenProtocol *proto, const char *from, long timestamp, XmlNode *bodyNode) { -// if (JabberListExist(LIST_CHATROOM, from)) { +// if (TlenListExist(LIST_CHATROOM, from)) { char *localMessage; char *nick, *style, *roomId, *userId; int iStyle; MUCCEVENT mucce; - roomId = JabberLoginFromJID(from); - userId = JabberResourceFromJID(from); + roomId = TlenLoginFromJID(from); + userId = TlenResourceFromJID(from); nick = getDisplayName(proto, userId); - localMessage = JabberTextDecode(bodyNode->text); + localMessage = TlenTextDecode(bodyNode->text); mucce.cbSize = sizeof(MUCCEVENT); mucce.iType = MUCC_EVENT_MESSAGE; mucce.pszID = roomId; @@ -388,28 +388,28 @@ int TlenMUCRecvMessage(TlenProtocol *proto, const char *from, long timestamp, Xm mucce.bIsMe = isSelf(proto, roomId, userId); mucce.dwFlags = 0; mucce.iFontSize = 0; - style = JabberXmlGetAttrValue(bodyNode, "f"); + style = TlenXmlGetAttrValue(bodyNode, "f"); if (style != NULL) { iStyle = atoi(style); if (iStyle & 1) mucce.dwFlags |= MUCC_EF_FONT_BOLD; if (iStyle & 2) mucce.dwFlags |= MUCC_EF_FONT_ITALIC; if (iStyle & 4) mucce.dwFlags |= MUCC_EF_FONT_UNDERLINE; } - style = JabberXmlGetAttrValue(bodyNode, "c"); + style = TlenXmlGetAttrValue(bodyNode, "c"); if (style != NULL && strlen(style) > 5) { iStyle = (stringToHex(style)<<16) | (stringToHex(style+2)<<8) | stringToHex(style+4); } else { iStyle = 0xFFFFFFFF; } mucce.color = (COLORREF) iStyle; - style = JabberXmlGetAttrValue(bodyNode, "s"); + style = TlenXmlGetAttrValue(bodyNode, "s"); if (style != NULL) { iStyle = atoi(style); } else { iStyle = 0; } mucce.iFontSize = iStyle; - style = JabberXmlGetAttrValue(bodyNode, "n"); + style = TlenXmlGetAttrValue(bodyNode, "n"); if (style != NULL) { iStyle = atoi(style)-1; } else { @@ -426,7 +426,7 @@ int TlenMUCRecvMessage(TlenProtocol *proto, const char *from, long timestamp, Xm } int TlenMUCRecvTopic(TlenProtocol *proto, const char *from, const char *subject) { -// if (JabberListExist(LIST_CHATROOM, from)) { +// if (TlenListExist(LIST_CHATROOM, from)) { MUCCEVENT mucce; mucce.cbSize = sizeof(MUCCEVENT); mucce.iType = MUCC_EVENT_TOPIC; @@ -443,13 +443,13 @@ int TlenMUCRecvError(TlenProtocol *proto, const char *from, XmlNode *errorNode) { int errCode; char str[512]; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; MUCCEVENT mucce; mucce.cbSize = sizeof(MUCCEVENT); mucce.iType = MUCC_EVENT_ERROR; mucce.pszID = from; mucce.pszModule = proto->m_szModuleName; - errCode = atoi(JabberXmlGetAttrValue(errorNode, "code")); + errCode = atoi(TlenXmlGetAttrValue(errorNode, "code")); switch (errCode) { case 403: mir_snprintf(str, SIZEOF(str), Translate("You cannot join this chat room, because you are banned.")); @@ -468,23 +468,23 @@ int TlenMUCRecvError(TlenProtocol *proto, const char *from, XmlNode *errorNode) break; case 411: mir_snprintf(str, SIZEOF(str), Translate("Nickname '%s' is already registered."), - JabberXmlGetAttrValue(errorNode, "n")); + TlenXmlGetAttrValue(errorNode, "n")); break; case 412: mir_snprintf(str, SIZEOF(str), Translate("Nickname already in use, please try another one. Hint: '%s' is free."), - JabberXmlGetAttrValue(errorNode, "free")); + TlenXmlGetAttrValue(errorNode, "free")); break; case 413: mir_snprintf(str, SIZEOF(str), Translate("You cannot register more than %s nicknames."), - JabberXmlGetAttrValue(errorNode, "num")); + TlenXmlGetAttrValue(errorNode, "num")); break; case 414: mir_snprintf(str, SIZEOF(str), Translate("You cannot create more than %s chat rooms."), - JabberXmlGetAttrValue(errorNode, "num")); + TlenXmlGetAttrValue(errorNode, "num")); break; case 415: mir_snprintf(str, SIZEOF(str), Translate("You cannot join more than %s chat rooms."), - JabberXmlGetAttrValue(errorNode, "num")); + TlenXmlGetAttrValue(errorNode, "num")); break; case 601: mir_snprintf(str, SIZEOF(str), Translate("Anonymous nicknames are not allowed in this chat room.")); @@ -498,19 +498,19 @@ int TlenMUCRecvError(TlenProtocol *proto, const char *from, XmlNode *errorNode) if (proto->isOnline) { switch (errCode) { case 412: - item = JabberListGetItemPtr(proto, LIST_CHATROOM, from); + item = TlenListGetItemPtr(proto, LIST_CHATROOM, from); if (item != NULL) { mucce.iType = MUCC_EVENT_JOIN; mucce.dwFlags = MUCC_EF_ROOM_NICKNAMES; mucce.pszModule = proto->m_szModuleName; mucce.pszID = from; mucce.pszName = item->roomName; - mucce.pszNick = JabberXmlGetAttrValue(errorNode, "free"); + mucce.pszNick = TlenXmlGetAttrValue(errorNode, "free"); CallService(MS_MUCC_EVENT, 0, (LPARAM) &mucce); } break; case 601: - item = JabberListGetItemPtr(proto, LIST_CHATROOM, from); + item = TlenListGetItemPtr(proto, LIST_CHATROOM, from); if (item != NULL) { mucce.iType = MUCC_EVENT_JOIN; mucce.dwFlags = 0; @@ -530,7 +530,7 @@ static int TlenMUCSendInvitation(TlenProtocol *proto, const char *roomID, const if (!proto->isOnline) { return 1; } - JabberSend(proto, "", roomID, user); + TlenSend(proto, "", roomID, user); return 0; } @@ -538,7 +538,7 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch { char str[512]; char *jid; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; if (!proto->isOnline) { return 1; } @@ -547,11 +547,11 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch } else { mir_snprintf(str, sizeof(str), "%s", roomID); } - if ((jid = JabberTextEncode(str)) != NULL) { + if ((jid = TlenTextEncode(str)) != NULL) { switch (desiredStatus) { case ID_STATUS_ONLINE: - JabberSend(proto, "

", jid); - item = JabberListGetItemPtr(proto, LIST_CHATROOM, roomID); + TlenSend(proto, "

", jid); + item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID); if (item != NULL) { if (item->nick != NULL) mir_free(item->nick); item->nick = NULL; @@ -561,10 +561,10 @@ static int TlenMUCSendPresence(TlenProtocol *proto, const char *roomID, const ch } break; default: - item = JabberListGetItemPtr(proto, LIST_CHATROOM, roomID); + item = TlenListGetItemPtr(proto, LIST_CHATROOM, roomID); if (item != NULL) { - JabberSend(proto, "

unavailable

", jid); - JabberListRemove(proto, LIST_CHATROOM, roomID); + TlenSend(proto, "

unavailable

", jid); + TlenListRemove(proto, LIST_CHATROOM, roomID); } break; } @@ -581,13 +581,13 @@ static int TlenMUCSendMessage(TlenProtocol *proto, MUCCEVENT *event) if (!proto->isOnline) { return 1; } - if ((msg = JabberTextEncode(event->pszText)) != NULL) { - if ((jid = JabberTextEncode(event->pszID)) != NULL) { + if ((msg = TlenTextEncode(event->pszText)) != NULL) { + if ((jid = TlenTextEncode(event->pszID)) != NULL) { style = 0; if (event->dwFlags & MUCC_EF_FONT_BOLD) style |=1; if (event->dwFlags & MUCC_EF_FONT_ITALIC) style |=2; if (event->dwFlags & MUCC_EF_FONT_UNDERLINE) style |=4; - JabberSend(proto, "%s", jid, event->iFont+1, event->iFontSize, style, event->color, msg); + TlenSend(proto, "%s", jid, event->iFont+1, event->iFontSize, style, event->color, msg); mir_free(jid); } mir_free(msg); @@ -601,9 +601,9 @@ static int TlenMUCSendTopic(TlenProtocol *proto, MUCCEVENT *event) if (!proto->isOnline) { return 1; } - if ((msg = JabberTextEncode(event->pszText)) != NULL) { - if ((jid = JabberTextEncode(event->pszID)) != NULL) { - JabberSend(proto, "%s", jid, msg); + if ((msg = TlenTextEncode(event->pszText)) != NULL) { + if ((jid = TlenTextEncode(event->pszID)) != NULL) { + TlenSend(proto, "%s", jid, msg); mir_free(jid); } mir_free(msg); @@ -618,27 +618,27 @@ static int TlenMUCSendQuery(TlenProtocol *proto, int type, const char *parent, i } if (type == 3) { // find chat room by name char serialId[32]; - JABBER_LIST_ITEM *item; - mir_snprintf(serialId, SIZEOF(serialId), JABBER_IQID"%d", JabberSerialNext(proto)); - item = JabberListAdd(proto, LIST_SEARCH, serialId); + TLEN_LIST_ITEM *item; + mir_snprintf(serialId, SIZEOF(serialId), TLEN_IQID"%d", TlenSerialNext(proto)); + item = TlenListAdd(proto, LIST_SEARCH, serialId); item->roomName = mir_strdup(parent); - JabberSend(proto, "", parent, serialId); + TlenSend(proto, "", parent, serialId); } else { if (parent == NULL) { - JabberSend(proto, "", type); + TlenSend(proto, "", type); } else { // 1 - groups, 2 - chat rooms, 7 - user nicks, 8 - user rooms if (type == 1 || (type == 2 && page == 0) || type == 7 || type == 8) { - JabberSend(proto, "", type, parent); + TlenSend(proto, "", type, parent); } else if (type == 2) { - JabberSend(proto, "", type, parent, page); + TlenSend(proto, "", type, parent, page); } else if (type == 6) { if (page) { - JabberSend(proto, "", type, parent); + TlenSend(proto, "", type, parent); } else { - JabberSend(proto, "", type, parent); + TlenSend(proto, "", type, parent); } } else if (type == 4) { // list of users, admins etc. - JabberSend(proto, "", parent, type, page); + TlenSend(proto, "", parent, type, page); } } } @@ -647,15 +647,15 @@ static int TlenMUCSendQuery(TlenProtocol *proto, int type, const char *parent, i int TlenMUCCreateWindow(TlenProtocol *proto, const char *roomID, const char *roomName, int roomFlags, const char *nick, const char *iqId) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; MUCCWINDOW mucw; if (!proto->isOnline || roomID == NULL) { return 1; } - if (JabberListExist(proto, LIST_CHATROOM, roomID)) { + if (TlenListExist(proto, LIST_CHATROOM, roomID)) { return 0; } - item = JabberListAdd(proto, LIST_CHATROOM, roomID); + item = TlenListAdd(proto, LIST_CHATROOM, roomID); if (roomName != NULL) { item->roomName = mir_strdup(roomName); } @@ -673,11 +673,11 @@ int TlenMUCCreateWindow(TlenProtocol *proto, const char *roomID, const char *roo mucw.pszStatusbarText = "hello"; CallService(MS_MUCC_NEW_WINDOW, 0, (LPARAM) &mucw); if (iqId != NULL) { - item = JabberListGetItemPtr(proto, LIST_INVITATIONS, iqId); + item = TlenListGetItemPtr(proto, LIST_INVITATIONS, iqId); if (item !=NULL) { TlenMUCSendInvitation(proto, roomID, item->nick); } - JabberListRemove(proto, LIST_INVITATIONS, iqId); + TlenListRemove(proto, LIST_INVITATIONS, iqId); } return 0; } @@ -708,12 +708,12 @@ void TlenIqResultChatGroups(TlenProtocol *proto, XmlNode *iqNode) int i, j; MUCCQUERYRESULT queryResult; - if ((lNode=JabberXmlGetChild(iqNode, "l")) == NULL) return; - p = JabberXmlGetAttrValue(iqNode, "p"); + if ((lNode=TlenXmlGetChild(iqNode, "l")) == NULL) return; + p = TlenXmlGetAttrValue(iqNode, "p"); if (p == NULL) { p=""; } - p = JabberTextDecode(p); + p = TlenTextDecode(p); queryResult.cbSize = sizeof (MUCCQUERYRESULT); queryResult.iType = MUCC_EVENT_QUERY_GROUPS; queryResult.pszModule = proto->m_szModuleName; @@ -724,14 +724,14 @@ void TlenIqResultChatGroups(TlenProtocol *proto, XmlNode *iqNode) itemNode = lNode->child[i]; if (!strcmp(itemNode->name, "i")) { queryResult.pItems[j].iCount = 0; - if ((f = JabberXmlGetAttrValue(itemNode, "f")) != NULL) { + if ((f = TlenXmlGetAttrValue(itemNode, "f")) != NULL) { queryResult.pItems[j].iCount = !strcmp(f, "3"); } - n = JabberXmlGetAttrValue(itemNode, "n"); - id = JabberXmlGetAttrValue(itemNode, "i"); + n = TlenXmlGetAttrValue(itemNode, "n"); + id = TlenXmlGetAttrValue(itemNode, "i"); if (n != NULL && id != NULL) { - queryResult.pItems[j].pszID = JabberTextDecode(id); - queryResult.pItems[j].pszName = JabberTextDecode(n); + queryResult.pItems[j].pszID = TlenTextDecode(id); + queryResult.pItems[j].pszName = TlenTextDecode(n); j++; } } @@ -749,13 +749,13 @@ void TlenIqResultChatRooms(TlenProtocol *proto, XmlNode *iqNode) int i, j; MUCCQUERYRESULT queryResult; - if ((lNode=JabberXmlGetChild(iqNode, "l")) == NULL) return; - if ((p = JabberXmlGetAttrValue(iqNode, "p")) == NULL) return; - pn = JabberXmlGetAttrValue(lNode, "n"); + if ((lNode=TlenXmlGetChild(iqNode, "l")) == NULL) return; + if ((p = TlenXmlGetAttrValue(iqNode, "p")) == NULL) return; + pn = TlenXmlGetAttrValue(lNode, "n"); if (pn == NULL) pn = "0"; - px = JabberXmlGetAttrValue(lNode, "x"); + px = TlenXmlGetAttrValue(lNode, "x"); if (px == NULL) px = "0"; - p = JabberTextDecode(p); + p = TlenTextDecode(p); queryResult.cbSize = sizeof (MUCCQUERYRESULT); queryResult.iType = MUCC_EVENT_QUERY_ROOMS; queryResult.pszModule = proto->m_szModuleName; @@ -767,12 +767,12 @@ void TlenIqResultChatRooms(TlenProtocol *proto, XmlNode *iqNode) for (i=j=0; inumChild; i++) { itemNode = lNode->child[i]; if (!strcmp(itemNode->name, "i")) { - n = JabberXmlGetAttrValue(itemNode, "n"); - c = JabberXmlGetAttrValue(itemNode, "c"); - x = JabberXmlGetAttrValue(itemNode, "x"); - if ((id=JabberXmlGetAttrValue(itemNode, "i")) != NULL) { - queryResult.pItems[j].pszID = JabberTextDecode(id); - queryResult.pItems[j].pszName = JabberTextDecode(n); + n = TlenXmlGetAttrValue(itemNode, "n"); + c = TlenXmlGetAttrValue(itemNode, "c"); + x = TlenXmlGetAttrValue(itemNode, "x"); + if ((id=TlenXmlGetAttrValue(itemNode, "i")) != NULL) { + queryResult.pItems[j].pszID = TlenTextDecode(id); + queryResult.pItems[j].pszName = TlenTextDecode(n); queryResult.pItems[j].iCount = atoi(c); queryResult.pItems[j].dwFlags = atoi(x); j++; @@ -790,7 +790,7 @@ void TlenIqResultUserRooms(TlenProtocol *proto, XmlNode *iqNode) char *id, *n; int i, j; MUCCQUERYRESULT queryResult; - if ((lNode=JabberXmlGetChild(iqNode, "l")) == NULL) return; + if ((lNode=TlenXmlGetChild(iqNode, "l")) == NULL) return; queryResult.cbSize = sizeof (MUCCQUERYRESULT); queryResult.iType = MUCC_EVENT_QUERY_USER_ROOMS; queryResult.pszModule = proto->m_szModuleName; @@ -799,11 +799,11 @@ void TlenIqResultUserRooms(TlenProtocol *proto, XmlNode *iqNode) for (i=j=0; inumChild; i++) { itemNode = lNode->child[i]; if (!strcmp(itemNode->name, "i")) { - n = JabberXmlGetAttrValue(itemNode, "n"); - id = JabberXmlGetAttrValue(itemNode, "i"); + n = TlenXmlGetAttrValue(itemNode, "n"); + id = TlenXmlGetAttrValue(itemNode, "i"); if (n != NULL && id != NULL) { - queryResult.pItems[j].pszID = JabberTextDecode(id); - queryResult.pItems[j].pszName = JabberTextDecode(n); + queryResult.pItems[j].pszID = TlenTextDecode(id); + queryResult.pItems[j].pszName = TlenTextDecode(n); j++; } } @@ -818,7 +818,7 @@ void TlenIqResultUserNicks(TlenProtocol *proto, XmlNode *iqNode) char *n; int i, j; MUCCQUERYRESULT queryResult; - if ((lNode=JabberXmlGetChild(iqNode, "l")) == NULL) return; + if ((lNode=TlenXmlGetChild(iqNode, "l")) == NULL) return; queryResult.cbSize = sizeof (MUCCQUERYRESULT); queryResult.iType = MUCC_EVENT_QUERY_USER_NICKS; queryResult.pszModule = proto->m_szModuleName; @@ -827,9 +827,9 @@ void TlenIqResultUserNicks(TlenProtocol *proto, XmlNode *iqNode) for (i=j=0; inumChild; i++) { itemNode = lNode->child[i]; if (!strcmp(itemNode->name, "i")) { - n = JabberXmlGetAttrValue(itemNode, "n"); - queryResult.pItems[j].pszID = NULL;//JabberTextDecode(n); - queryResult.pItems[j].pszName = JabberTextDecode(n); + n = TlenXmlGetAttrValue(itemNode, "n"); + queryResult.pItems[j].pszID = NULL;//TlenTextDecode(n); + queryResult.pItems[j].pszName = TlenTextDecode(n); j++; } } @@ -843,8 +843,8 @@ void TlenIqResultChatRoomUsers(TlenProtocol *proto, XmlNode *iqNode) char *id, *n; int i, j; MUCCQUERYRESULT queryResult; - if ((lNode=JabberXmlGetChild(iqNode, "l")) == NULL) return; - if ((id=JabberXmlGetAttrValue(iqNode, "from")) == NULL) return; + if ((lNode=TlenXmlGetChild(iqNode, "l")) == NULL) return; + if ((id=TlenXmlGetAttrValue(iqNode, "from")) == NULL) return; queryResult.cbSize = sizeof (MUCCQUERYRESULT); queryResult.iType = MUCC_EVENT_QUERY_USERS; queryResult.pszModule = proto->m_szModuleName; @@ -854,26 +854,26 @@ void TlenIqResultChatRoomUsers(TlenProtocol *proto, XmlNode *iqNode) for (i=j=0; inumChild; i++) { itemNode = lNode->child[i]; if (!strcmp(itemNode->name, "i")) { - id = JabberXmlGetAttrValue(itemNode, "i"); + id = TlenXmlGetAttrValue(itemNode, "i"); if (id != NULL) { - queryResult.pItems[j].pszID = JabberTextDecode(id); - n = JabberXmlGetAttrValue(itemNode, "n"); + queryResult.pItems[j].pszID = TlenTextDecode(id); + n = TlenXmlGetAttrValue(itemNode, "n"); if (n != NULL) { - queryResult.pItems[j].pszName = JabberTextDecode(n); + queryResult.pItems[j].pszName = TlenTextDecode(n); } - n = JabberXmlGetAttrValue(itemNode, "a"); + n = TlenXmlGetAttrValue(itemNode, "a"); if (n != NULL) { - queryResult.pItems[j].pszNick = JabberTextDecode(n); + queryResult.pItems[j].pszNick = TlenTextDecode(n); } - n = JabberXmlGetAttrValue(itemNode, "r"); + n = TlenXmlGetAttrValue(itemNode, "r"); if (n != NULL) { - queryResult.pItems[j].pszText = JabberTextDecode(n); + queryResult.pItems[j].pszText = TlenTextDecode(n); } - n = JabberXmlGetAttrValue(itemNode, "e"); + n = TlenXmlGetAttrValue(itemNode, "e"); if (n != NULL) { queryResult.pItems[j].iCount = atoi(n); } - n = JabberXmlGetAttrValue(itemNode, "s"); + n = TlenXmlGetAttrValue(itemNode, "s"); if (n != NULL) { queryResult.pItems[j].dwFlags = atoi(n); } @@ -889,12 +889,12 @@ void TlenIqResultChatRoomUsers(TlenProtocol *proto, XmlNode *iqNode) void TlenIqResultRoomSearch(TlenProtocol *proto, XmlNode *iqNode) { char *iqId, *id; - JABBER_LIST_ITEM *item; - iqId=JabberXmlGetAttrValue(iqNode, "id"); - item=JabberListGetItemPtr(proto, LIST_SEARCH, iqId); - if ((id=JabberXmlGetAttrValue(iqNode, "i")) != NULL) { + TLEN_LIST_ITEM *item; + iqId=TlenXmlGetAttrValue(iqNode, "id"); + item=TlenListGetItemPtr(proto, LIST_SEARCH, iqId); + if ((id=TlenXmlGetAttrValue(iqNode, "i")) != NULL) { MUCCEVENT mucce; - id = JabberTextDecode(id); + id = TlenTextDecode(id); mucce.cbSize = sizeof(MUCCEVENT); mucce.iType = MUCC_EVENT_JOIN; mucce.pszModule = proto->m_szModuleName; @@ -908,19 +908,19 @@ void TlenIqResultRoomSearch(TlenProtocol *proto, XmlNode *iqNode) CallService(MS_MUCC_EVENT, 0, (LPARAM) &mucce); mir_free(id); } - JabberListRemove(proto, LIST_SEARCH, iqId); + TlenListRemove(proto, LIST_SEARCH, iqId); } void TlenIqResultRoomInfo(TlenProtocol *proto, XmlNode *iqNode) { char *id, *name, *group, *flags; - if ((id=JabberXmlGetAttrValue(iqNode, "from")) != NULL) { - if ((name=JabberXmlGetAttrValue(iqNode, "n")) != NULL) { + if ((id=TlenXmlGetAttrValue(iqNode, "from")) != NULL) { + if ((name=TlenXmlGetAttrValue(iqNode, "n")) != NULL) { MUCCEVENT mucce; - group = JabberXmlGetAttrValue(iqNode, "cn"); - flags = JabberXmlGetAttrValue(iqNode, "x"); - id = JabberTextDecode(id); - name = JabberTextDecode(name); + group = TlenXmlGetAttrValue(iqNode, "cn"); + flags = TlenXmlGetAttrValue(iqNode, "x"); + id = TlenTextDecode(id); + name = TlenTextDecode(name); mucce.cbSize = sizeof(MUCCEVENT); mucce.iType = MUCC_EVENT_ROOM_INFO; mucce.pszModule = proto->m_szModuleName; @@ -996,7 +996,7 @@ static int TlenMUCQueryContacts(TlenProtocol *proto, const char *roomId) { MUCSENDQUERYTHREADDATA *threadData = (MUCSENDQUERYTHREADDATA *)mir_alloc(sizeof(MUCSENDQUERYTHREADDATA)); threadData->proto = proto; threadData->roomId = mir_strdup(roomId); - JabberForkThread(TlenMUCCSendQueryResultThread, 0, (void *)threadData); + TlenForkThread(TlenMUCCSendQueryResultThread, 0, (void *)threadData); return 1; } @@ -1005,7 +1005,7 @@ INT_PTR TlenProtocol::MUCMenuHandleMUC(WPARAM wParam, LPARAM lParam) if (!isOnline) return 1; - JabberSend(this, "

", JabberSerialNext(this)); + TlenSend(this, "

", TlenSerialNext(this)); return 0; } @@ -1027,17 +1027,17 @@ INT_PTR TlenProtocol::MUCContactMenuHandleMUC(WPARAM wParam, LPARAM lParam) { HANDLE hContact; DBVARIANT dbv; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; if (!isOnline) return 1; if ((hContact=(HANDLE) wParam) != NULL && isOnline) { if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { char serialId[32]; - mir_snprintf(serialId, SIZEOF(serialId), JABBER_IQID"%d", JabberSerialNext(this)); - item = JabberListAdd(this, LIST_INVITATIONS, serialId); + mir_snprintf(serialId, SIZEOF(serialId), TLEN_IQID"%d", TlenSerialNext(this)); + item = TlenListAdd(this, LIST_INVITATIONS, serialId); item->nick = mir_strdup(dbv.pszVal); - JabberSend(this, "

", serialId); + TlenSend(this, "

", serialId); db_free(&dbv); } } diff --git a/protocols/Tlen/src/tlen_opt.cpp b/protocols/Tlen/src/tlen_opt.cpp index 4c0be5e564..ceb5afe8e7 100644 --- a/protocols/Tlen/src/tlen_opt.cpp +++ b/protocols/Tlen/src/tlen_opt.cpp @@ -99,7 +99,7 @@ int TlenProtocol::OptionsInit(WPARAM wParam, LPARAM lParam) return 0; } -static LRESULT CALLBACK JabberValidateUsernameWndProc(HWND hwndEdit, UINT msg, WPARAM wParam, LPARAM lParam) +static LRESULT CALLBACK TlenValidateUsernameWndProc(HWND hwndEdit, UINT msg, WPARAM wParam, LPARAM lParam) { switch (msg) { case WM_CHAR: @@ -107,7 +107,7 @@ static LRESULT CALLBACK JabberValidateUsernameWndProc(HWND hwndEdit, UINT msg, W return 0; break; } - return mir_callNextSubclass(hwndEdit, JabberValidateUsernameWndProc, msg, wParam, lParam); + return mir_callNextSubclass(hwndEdit, TlenValidateUsernameWndProc, msg, wParam, lParam); } INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -133,7 +133,7 @@ INT_PTR CALLBACK TlenAccMgrUIDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR } CheckDlgButton(hwndDlg, IDC_SAVEPASSWORD, db_get_b(NULL, proto->m_szModuleName, "SavePassword", TRUE)); - mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), JabberValidateUsernameWndProc); + mir_subclassWindow(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), TlenValidateUsernameWndProc); } return TRUE; @@ -251,7 +251,7 @@ static INT_PTR CALLBACK TlenBasicOptDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara oldProc = (WNDPROC) GetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), GWLP_WNDPROC); SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), GWLP_USERDATA, (LONG_PTR) oldProc); - SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), GWLP_WNDPROC, (LONG_PTR) JabberValidateUsernameWndProc); + SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_EDIT_USERNAME), GWLP_WNDPROC, (LONG_PTR) TlenValidateUsernameWndProc); return TRUE; } case WM_COMMAND: diff --git a/protocols/Tlen/src/tlen_p2p_new.cpp b/protocols/Tlen/src/tlen_p2p_new.cpp index c09a1f61ba..74e7e28f8d 100644 --- a/protocols/Tlen/src/tlen_p2p_new.cpp +++ b/protocols/Tlen/src/tlen_p2p_new.cpp @@ -48,7 +48,7 @@ static void logInfo(const char *filename, const char *fmt, ...) { void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft) { - JabberLog(ft->proto, "P2P receive thread started"); + TlenLog(ft->proto, "P2P receive thread started"); ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); // ft->mode = FT_RECV; // ft->currentFile = 0; @@ -103,19 +103,19 @@ void __cdecl TlenNewFileReceiveThread(TLEN_FILE_TRANSFER *ft) closesocket(ft->udps); } - JabberListRemove(ft->proto, LIST_FILE, ft->iqId); + TlenListRemove(ft->proto, LIST_FILE, ft->iqId); if (ft->state == FT_DONE) ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); else { ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - JabberLog(ft->proto, "P2P receive thread ended"); + TlenLog(ft->proto, "P2P receive thread ended"); TlenP2PFreeFileTransfer(ft); } void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft) { - JabberLog(ft->proto, "P2P send thread started"); + TlenLog(ft->proto, "P2P send thread started"); // ft->mode = FT_RECV; // ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); // ft->currentFile = 0; @@ -165,12 +165,12 @@ void __cdecl TlenNewFileSendThread(TLEN_FILE_TRANSFER *ft) SleepEx(1000, TRUE); } } - JabberLog(ft->proto, "P2P send thread ended"); + TlenLog(ft->proto, "P2P send thread ended"); } void TlenBindUDPSocket(TLEN_FILE_TRANSFER *ft) { - JabberLog(ft->proto, "Binding UDP socket"); + TlenLog(ft->proto, "Binding UDP socket"); ft->udps = socket(PF_INET, SOCK_DGRAM, 0); if (ft->udps != INVALID_SOCKET) { SOCKADDR_IN sin; @@ -192,7 +192,7 @@ void TlenBindUDPSocket(TLEN_FILE_TRANSFER *ft) ft->wLocalPort = ntohs(sin.sin_port); ft->localName= mir_strdup(host_name); - JabberLog(ft->proto, "UDP socket bound to %s:%d", ft->localName, ft->wLocalPort); + TlenLog(ft->proto, "UDP socket bound to %s:%d", ft->localName, ft->wLocalPort); } } } @@ -221,20 +221,20 @@ B SEND: jid = mir_strdup(from); ft->proto = info->proto; - ft->hContact = JabberHContactFromJID(info->proto, from); + ft->hContact = TlenHContactFromJID(info->proto, from); ft->iqId = mir_strdup(id); ft->fileTotalSize = atoi(s); ft->newP2P = TRUE; - if ((item=JabberListAdd(ft->proto, LIST_FILE, ft->iqId)) != NULL) { + if ((item=TlenListAdd(ft->proto, LIST_FILE, ft->iqId)) != NULL) { char fileInfo[128]; item->ft = ft; mir_snprintf(fileInfo, sizeof(fileInfo), "%s file(s), %s bytes", c, s); @@ -269,7 +269,7 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { pre.tszDescription = filenameT; pre.ptszFiles = &filenameT; pre.lParam = (LPARAM)ft; - JabberLog(ft->proto, "sending chainrecv"); + TlenLog(ft->proto, "sending chainrecv"); ProtoChainRecvFile(ft->hContact, &pre); mir_free(filenameT); } @@ -279,10 +279,10 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { /* transfer denied */ } else if (!strcmp(e, "5")) { /* transfer accepted */ - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) { item->id2 = mir_strdup("84273372"); item->ft->id2 = mir_strdup("84273372"); - JabberSend(info->proto, "", from, item->id2, id); + TlenSend(info->proto, "", from, item->id2, id); } } } @@ -290,10 +290,10 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { } else if (dcng != NULL) { char *s, *id, *id2; - JabberLog(info->proto, "DCNG"); - s = JabberXmlGetAttrValue(dcng, "s"); - id2 = JabberXmlGetAttrValue(dcng, "i"); - id = JabberXmlGetAttrValue(dcng, "mi"); + TlenLog(info->proto, "DCNG"); + s = TlenXmlGetAttrValue(dcng, "s"); + id2 = TlenXmlGetAttrValue(dcng, "i"); + id = TlenXmlGetAttrValue(dcng, "mi"); if (!strcmp(s, "1")) { /* Keys */ /* n - name (file_send) */ @@ -306,41 +306,41 @@ void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info) { /* iv - aes initial vector */ /* mi - p2p connection id */ char *n, *k, *v, *ck, *iv; - n = JabberXmlGetAttrValue(dcng, "n"); - k = JabberXmlGetAttrValue(dcng, "k"); - v = JabberXmlGetAttrValue(dcng, "v"); - ck = JabberXmlGetAttrValue(dcng, "ck"); - iv = JabberXmlGetAttrValue(dcng, "iv"); + n = TlenXmlGetAttrValue(dcng, "n"); + k = TlenXmlGetAttrValue(dcng, "k"); + v = TlenXmlGetAttrValue(dcng, "v"); + ck = TlenXmlGetAttrValue(dcng, "ck"); + iv = TlenXmlGetAttrValue(dcng, "iv"); if (!strcmp(n, "file_send")) { - if ((item=JabberListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_FILE, id)) != NULL) { item->id2 = mir_strdup(id2); item->ft->id2 = mir_strdup(id2); TlenBindUDPSocket(item->ft); - JabberSend(info->proto, "", + TlenSend(info->proto, "", item->ft->jid, item->ft->localName, item->ft->wLocalPort, item->ft->localName, item->ft->wLocalPort, item->ft->id2); } } } else if (!strcmp(s, "2")) { - JabberLog(info->proto, "step = 2"); - JabberLog(info->proto, "%s",from); - JabberLog(info->proto, "%s",id2); + TlenLog(info->proto, "step = 2"); + TlenLog(info->proto, "%s",from); + TlenLog(info->proto, "%s",id2); /* IP and port */ - if ((item=JabberListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { - item->ft->hostName = mir_strdup(JabberXmlGetAttrValue(dcng, "pa")); - item->ft->wPort = atoi(JabberXmlGetAttrValue(dcng, "pp")); + if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { + item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa")); + item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp")); TlenBindUDPSocket(item->ft); - JabberSend(info->proto, "", + TlenSend(info->proto, "", item->ft->jid, item->ft->localName, item->ft->wLocalPort, item->ft->localName, item->ft->wLocalPort, item->ft->id2); - JabberForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft); - JabberForkThread((void (__cdecl *)(void*))TlenNewFileSendThread, 0, item->ft); + TlenForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft); + TlenForkThread((void (__cdecl *)(void*))TlenNewFileSendThread, 0, item->ft); } } else if (!strcmp(s, "4")) { /* IP and port */ - if ((item=JabberListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { - JabberLog(info->proto, "step = 4"); - item->ft->hostName = mir_strdup(JabberXmlGetAttrValue(dcng, "pa")); - item->ft->wPort = atoi(JabberXmlGetAttrValue(dcng, "pp")); - JabberForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft); + if ((item=TlenListFindItemPtrById2(info->proto, LIST_FILE, id2)) != NULL) { + TlenLog(info->proto, "step = 4"); + item->ft->hostName = mir_strdup(TlenXmlGetAttrValue(dcng, "pa")); + item->ft->wPort = atoi(TlenXmlGetAttrValue(dcng, "pp")); + TlenForkThread((void (__cdecl *)(void*))TlenNewFileReceiveThread, 0, item->ft); } } diff --git a/protocols/Tlen/src/tlen_p2p_old.cpp b/protocols/Tlen/src/tlen_p2p_old.cpp index 1f51178bd1..4eb07d5be6 100644 --- a/protocols/Tlen/src/tlen_p2p_old.cpp +++ b/protocols/Tlen/src/tlen_p2p_old.cpp @@ -114,7 +114,7 @@ void TlenP2PInit() { void TlenP2PUninit() { } -int TlenP2PPacketSend(JABBER_SOCKET s, TLEN_FILE_PACKET *packet) +int TlenP2PPacketSend(TLEN_SOCKET s, TLEN_FILE_PACKET *packet) { DWORD sendResult; if (packet != NULL && packet->packet != NULL) { @@ -126,7 +126,7 @@ int TlenP2PPacketSend(JABBER_SOCKET s, TLEN_FILE_PACKET *packet) return 1; } -TLEN_FILE_PACKET* TlenP2PPacketReceive(JABBER_SOCKET s) +TLEN_FILE_PACKET* TlenP2PPacketReceive(TLEN_SOCKET s) { TLEN_FILE_PACKET *packet; DWORD recvResult; @@ -158,7 +158,7 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) TLEN_FILE_PACKET *packet; TlenProtocol *proto = ft->proto; - JabberLog(proto, "Establishing outgoing connection."); + TlenLog(proto, "Establishing outgoing connection."); ft->state = FT_ERROR; if ((packet = TlenP2PPacketCreate(2*sizeof(DWORD) + 20)) != NULL) { TlenP2PPacketSetType(packet, TLEN_FILE_PACKET_CONNECTION_REQUEST); @@ -185,9 +185,9 @@ void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck) } } -TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, JABBER_SOCKET s, JABBER_LIST list, BOOL sendAck) +TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, TLEN_SOCKET s, TLEN_LIST list, BOOL sendAck) { - JABBER_LIST_ITEM *item = NULL; + TLEN_LIST_ITEM *item = NULL; TLEN_FILE_PACKET *packet; int i; char str[300]; @@ -206,13 +206,13 @@ TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, JABB } iqId = *((DWORD *)(packet->packet+sizeof(DWORD))); i = 0; - while ((i=JabberListFindNext(proto, list, i)) >= 0) { - if ((item=JabberListGetItemPtrFromIndex(proto, i)) != NULL) { + while ((i=TlenListFindNext(proto, list, i)) >= 0) { + if ((item=TlenListGetItemPtrFromIndex(proto, i)) != NULL) { mir_snprintf(str, sizeof(str), "%d", iqId); if (!strcmp(item->ft->iqId, str)) { char *hash, *nick; int j; - nick = JabberNickFromJID(item->ft->jid); + nick = TlenNickFromJID(item->ft->jid); mir_snprintf(str, sizeof(str), "%08X%s%d", iqId, nick, iqId); mir_free(nick); hash = TlenSha1(str, (int)strlen(str)); @@ -248,9 +248,9 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft) BYTE buf[8]; int status; -// JabberLog("Waiting for the file to be sent via SOCKS..."); +// TlenLog("Waiting for the file to be sent via SOCKS..."); status = Netlib_Recv(ft->s, (char*)buf, 8, MSG_NODUMP); -// JabberLog("accepted connection !!!"); +// TlenLog("accepted connection !!!"); if ( status == SOCKET_ERROR || status < 8 || buf[1] != 90) { status = 1; } else { @@ -263,7 +263,7 @@ static void __cdecl TlenFileBindSocks4Thread(TLEN_FILE_TRANSFER* ft) ft->state = FT_ERROR; } } - JabberLog(ft->proto, "Closing connection for this file transfer..."); + TlenLog(ft->proto, "Closing connection for this file transfer..."); // Netlib_CloseHandle(ft->s); if (ft->hFileEvent != NULL) SetEvent(ft->hFileEvent); @@ -274,9 +274,9 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft) BYTE buf[256]; int status; -// JabberLog("Waiting for the file to be sent via SOCKS..."); +// TlenLog("Waiting for the file to be sent via SOCKS..."); status = Netlib_Recv(ft->s, (char*)buf, sizeof(buf), MSG_NODUMP); -// JabberLog("accepted connection !!!"); +// TlenLog("accepted connection !!!"); if ( status == SOCKET_ERROR || status < 7 || buf[1] != 0) { status = 1; } else { @@ -289,21 +289,21 @@ static void __cdecl TlenFileBindSocks5Thread(TLEN_FILE_TRANSFER* ft) ft->state = FT_ERROR; } } -// JabberLog("Closing connection for this file transfer..."); +// TlenLog("Closing connection for this file transfer..."); // Netlib_CloseHandle(ft->s); if (ft->hFileEvent != NULL) SetEvent(ft->hFileEvent); } -static JABBER_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) +static TLEN_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) { //rfc1928 int len; BYTE buf[256]; int status; struct in_addr in; NETLIBOPENCONNECTION nloc; - JABBER_SOCKET s; + TLEN_SOCKET s; nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = sb->szHost; @@ -311,7 +311,7 @@ static JABBER_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) nloc.flags = 0; s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc); if (s == NULL) { -// JabberLog("Connection failed (%d), thread ended", WSAGetLastError()); +// TlenLog("Connection failed (%d), thread ended", WSAGetLastError()); return NULL; } buf[0] = 4; //socks4 @@ -328,19 +328,19 @@ static JABBER_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) len += 9; status = Netlib_Send(s, (char*)buf, len, MSG_NODUMP); if (status == SOCKET_ERROR || status < len) { -// JabberLog("Send failed (%d), thread ended", WSAGetLastError()); +// TlenLog("Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, 8, MSG_NODUMP); if (status == SOCKET_ERROR || status < 8 || buf[1] != 90) { -// JabberLog("SOCKS4 negotiation failed"); +// TlenLog("SOCKS4 negotiation failed"); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP); if ( status == SOCKET_ERROR || status < 7 || buf[0] != 5 || buf[1] != 0) { -// JabberLog("SOCKS5 request failed"); +// TlenLog("SOCKS5 request failed"); Netlib_CloseHandle(s); return NULL; } @@ -348,17 +348,17 @@ static JABBER_SOCKET TlenP2PBindSocks4(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) strcpy(sb->szHost, inet_ntoa(in)); sb->wPort = htons(*(PWORD)(buf+2)); ft->s = s; - JabberForkThread((void (__cdecl *)(void*))TlenFileBindSocks4Thread, 0, ft); + TlenForkThread((void (__cdecl *)(void*))TlenFileBindSocks4Thread, 0, ft); return s; } -static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) +static TLEN_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) { //rfc1928 BYTE buf[512]; int len, status; NETLIBOPENCONNECTION nloc; struct in_addr in; - JABBER_SOCKET s; + TLEN_SOCKET s; nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = sb->szHost; @@ -366,7 +366,7 @@ static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) nloc.flags = 0; s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hFileNetlibUser, (LPARAM) &nloc); if (s == NULL) { - JabberLog(ft->proto, "Connection failed (%d), thread ended", WSAGetLastError()); + TlenLog(ft->proto, "Connection failed (%d), thread ended", WSAGetLastError()); return NULL; } buf[0] = 5; //yep, socks5 @@ -374,13 +374,13 @@ static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) buf[2] = sb->useAuth?2:0; // authorization status = Netlib_Send(s, (char*)buf, 3, MSG_NODUMP); if (status == SOCKET_ERROR || status < 3) { - JabberLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); + TlenLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, 2, MSG_NODUMP); if (status == SOCKET_ERROR || status < 2 || (buf[1] != 0 && buf[1] != 2)) { - JabberLog(ft->proto, "SOCKS5 negotiation failed"); + TlenLog(ft->proto, "SOCKS5 negotiation failed"); Netlib_CloseHandle(s); return NULL; } @@ -399,13 +399,13 @@ static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) status = Netlib_Send(s, (char*)pAuthBuf, 3+nUserLen+nPassLen, MSG_NODUMP); mir_free(pAuthBuf); if (status == SOCKET_ERROR || status < 3 + nUserLen+nPassLen) { - JabberLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); + TlenLog(ft->proto, "Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP); if (status == SOCKET_ERROR || status < 2 || buf[1] != 0) { - JabberLog(ft->proto, "SOCKS5 sub-negotiation failed"); + TlenLog(ft->proto, "SOCKS5 sub-negotiation failed"); Netlib_CloseHandle(s); return NULL; } @@ -424,14 +424,14 @@ static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) status = Netlib_Send(s, (char*)pInit, 6+nHostLen, MSG_NODUMP); mir_free(pInit); if (status == SOCKET_ERROR || status < 6 + nHostLen) { -// JabberLog("Send failed (%d), thread ended", WSAGetLastError()); +// TlenLog("Send failed (%d), thread ended", WSAGetLastError()); Netlib_CloseHandle(s); return NULL; } } status = Netlib_Recv(s, (char*)buf, sizeof(buf), MSG_NODUMP); if ( status == SOCKET_ERROR || status < 7 || buf[0] != 5 || buf[1] != 0) { -// JabberLog("SOCKS5 request failed"); +// TlenLog("SOCKS5 request failed"); Netlib_CloseHandle(s); return NULL; } @@ -448,15 +448,15 @@ static JABBER_SOCKET TlenP2PBindSocks5(SOCKSBIND * sb, TLEN_FILE_TRANSFER *ft) sb->wPort = htons(*(PWORD)(buf+len)); ft->s = s; - JabberForkThread((void (__cdecl *)(void*))TlenFileBindSocks5Thread, 0, ft); + TlenForkThread((void (__cdecl *)(void*))TlenFileBindSocks5Thread, 0, ft); return s; } -JABBER_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft) +TLEN_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft) { NETLIBBIND nlb = {0}; - JABBER_SOCKET s = NULL; + TLEN_SOCKET s = NULL; int useProxy; DBVARIANT dbv; SOCKSBIND sb; @@ -509,9 +509,9 @@ JABBER_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft) nlb.pfnNewConnectionV2 = ft->pfnNewConnectionV2; nlb.wPort = 0; // Use user-specified incoming port ranges, if available nlb.pExtra = proto; - JabberLog(ft->proto, "Calling MS_NETLIB_BINDPORT"); + TlenLog(ft->proto, "Calling MS_NETLIB_BINDPORT"); s = (HANDLE) CallService(MS_NETLIB_BINDPORT, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nlb); - JabberLog(ft->proto, "listening on %d",s); + TlenLog(ft->proto, "listening on %d",s); } if (useProxy == 0) { in.S_un.S_addr = htonl(nlb.dwExternalIP); @@ -525,7 +525,7 @@ JABBER_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft) return s; } -void TlenP2PStopListening(JABBER_SOCKET s) { +void TlenP2PStopListening(TLEN_SOCKET s) { if (s != NULL) { // listenCount--; // if (listenCount <= 0) { diff --git a/protocols/Tlen/src/tlen_p2p_old.h b/protocols/Tlen/src/tlen_p2p_old.h index 620d091351..4ce48e2b26 100644 --- a/protocols/Tlen/src/tlen_p2p_old.h +++ b/protocols/Tlen/src/tlen_p2p_old.h @@ -57,12 +57,12 @@ extern void TlenP2PPacketSetType(TLEN_FILE_PACKET *packet, DWORD type); extern void TlenP2PPacketSetLen(TLEN_FILE_PACKET *packet, DWORD len); extern void TlenP2PPacketPackDword(TLEN_FILE_PACKET *packet, DWORD data); extern void TlenP2PPacketPackBuffer(TLEN_FILE_PACKET *packet, char *buffer, int len); -extern int TlenP2PPacketSend(JABBER_SOCKET s, TLEN_FILE_PACKET *packet); -extern TLEN_FILE_PACKET* TlenP2PPacketReceive(JABBER_SOCKET s); +extern int TlenP2PPacketSend(TLEN_SOCKET s, TLEN_FILE_PACKET *packet); +extern TLEN_FILE_PACKET* TlenP2PPacketReceive(TLEN_SOCKET s); extern void TlenP2PEstablishOutgoingConnection(TLEN_FILE_TRANSFER *ft, BOOL sendAck); -extern TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, JABBER_SOCKET s, JABBER_LIST list, BOOL sendAck); -extern JABBER_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft); -extern void TlenP2PStopListening(JABBER_SOCKET s); +extern TLEN_FILE_TRANSFER* TlenP2PEstablishIncomingConnection(TlenProtocol *proto, TLEN_SOCKET s, TLEN_LIST list, BOOL sendAck); +extern TLEN_SOCKET TlenP2PListen(TLEN_FILE_TRANSFER *ft); +extern void TlenP2PStopListening(TLEN_SOCKET s); void __cdecl TlenProcessP2P(XmlNode *node, void *userdata); diff --git a/protocols/Tlen/src/tlen_picture.cpp b/protocols/Tlen/src/tlen_picture.cpp index 407eb6067d..d121d0984e 100644 --- a/protocols/Tlen/src/tlen_picture.cpp +++ b/protocols/Tlen/src/tlen_picture.cpp @@ -27,7 +27,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. typedef struct { TlenProtocol *proto; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; } TLENPSREQUESTTHREADDATA; static void LogPictureMessage(TlenProtocol *proto, const char *jid, const char *filename, BOOL isSent) @@ -35,14 +35,14 @@ static void LogPictureMessage(TlenProtocol *proto, const char *jid, const char * char message[1024]; const char *msg = isSent ? LPGEN("Image sent file://%s") : LPGEN("Image received file://%s"); mir_snprintf(message, sizeof(message), Translate(msg), filename); - TlenLogMessage(proto, JabberHContactFromJID(proto, jid), isSent ? DBEF_SENT : 0, message); + TlenLogMessage(proto, TlenHContactFromJID(proto, jid), isSent ? DBEF_SENT : 0, message); } static void TlenPsPostThread(void *ptr) { TLENPSREQUESTTHREADDATA *data = (TLENPSREQUESTTHREADDATA *)ptr; TlenProtocol *proto = data->proto; - JABBER_LIST_ITEM *item = data->item; - JABBER_SOCKET socket = JabberWsConnect(proto, "ps.tlen.pl", 443); + TLEN_LIST_ITEM *item = data->item; + TLEN_SOCKET socket = TlenWsConnect(proto, "ps.tlen.pl", 443); BOOL bSent = FALSE; if (socket != NULL) { char header[512]; @@ -50,7 +50,7 @@ static void TlenPsPostThread(void *ptr) { item->ft->s = socket; item->ft->hFileEvent = CreateEvent(NULL, FALSE, FALSE, NULL); mir_snprintf(header, sizeof(header), "", proto->threadData->username, item->ft->jid, item->ft->fileTotalSize, item->jid); - JabberWsSend(proto, socket, header, (int)strlen(header)); + TlenWsSend(proto, socket, header, (int)strlen(header)); ret = WaitForSingleObject(item->ft->hFileEvent, 1000 * 60 * 5); if (ret == WAIT_OBJECT_0) { FILE *fp = fopen( item->ft->files[0], "rb" ); @@ -59,14 +59,14 @@ static void TlenPsPostThread(void *ptr) { char header[512]; char fileBuffer[2048]; mir_snprintf(header, sizeof(header), "", item->ft->iqId, item->jid); - JabberWsSend(proto, socket, header, (int)strlen(header)); - JabberLog(proto, "Sending picture data..."); + TlenWsSend(proto, socket, header, (int)strlen(header)); + TlenLog(proto, "Sending picture data..."); for (i = item->ft->filesSize[0]; i > 0; ) { int toread = min(2048, i); int readcount = (int)fread(fileBuffer, (size_t)1, (size_t)toread, fp); i -= readcount; if (readcount > 0) { - JabberWsSend(proto, socket, fileBuffer, readcount); + TlenWsSend(proto, socket, fileBuffer, readcount); } if (toread != readcount) { break; @@ -83,46 +83,46 @@ static void TlenPsPostThread(void *ptr) { } Netlib_CloseHandle(socket); if (bSent) { - JabberSend(proto, "", item->ft->jid, item->jid, item->ft->id2); + TlenSend(proto, "", item->ft->jid, item->jid, item->ft->id2); LogPictureMessage(proto, item->ft->jid, item->ft->files[0], TRUE); } TlenP2PFreeFileTransfer(item->ft); - JabberListRemove(proto, LIST_PICTURE, item->jid); + TlenListRemove(proto, LIST_PICTURE, item->jid); } else { /* cannot connect to ps server */ } mir_free(data); } -static void TlenPsPost(TlenProtocol *proto, JABBER_LIST_ITEM *item) { +static void TlenPsPost(TlenProtocol *proto, TLEN_LIST_ITEM *item) { TLENPSREQUESTTHREADDATA *threadData = (TLENPSREQUESTTHREADDATA *)mir_alloc(sizeof(TLENPSREQUESTTHREADDATA)); threadData->proto = proto; threadData->item = item; - JabberForkThread(TlenPsPostThread, 0, threadData); + TlenForkThread(TlenPsPostThread, 0, threadData); } static void TlenPsGetThread(void *ptr) { TLENPSREQUESTTHREADDATA *data = (TLENPSREQUESTTHREADDATA *)ptr; TlenProtocol *proto = data->proto; - JABBER_LIST_ITEM *item = data->item; + TLEN_LIST_ITEM *item = data->item; FILE *fp; fp = fopen( item->ft->files[0], "wb" ); if (fp) { - JABBER_SOCKET socket = JabberWsConnect(proto, "ps.tlen.pl", 443); + TLEN_SOCKET socket = TlenWsConnect(proto, "ps.tlen.pl", 443); if (socket != NULL) { XmlState xmlState; char header[512]; char fileBuffer[2048]; - JabberXmlInitState(&xmlState); + TlenXmlInitState(&xmlState); mir_snprintf(header, sizeof(header), "", proto->threadData->username, item->ft->jid, item->jid, item->ft->id2); - JabberWsSend(proto, socket, header, (int)strlen(header)); - JabberLog(proto, "Reveiving picture data..."); + TlenWsSend(proto, socket, header, (int)strlen(header)); + TlenLog(proto, "Reveiving picture data..."); { int totalcount = 0; int size = item->ft->filesSize[0]; BOOL bHeader = TRUE; while (TRUE) { - int readcount = JabberWsRecv(proto, socket, fileBuffer, 2048 - totalcount); + int readcount = TlenWsRecv(proto, socket, fileBuffer, 2048 - totalcount); if (readcount == 0) { break; } @@ -131,7 +131,7 @@ static void TlenPsGetThread(void *ptr) { char * tagend = (char*)memchr(fileBuffer, '/', totalcount); tagend = (char*)memchr(tagend + 1, '>', totalcount - (tagend - fileBuffer) - 1); if (tagend != NULL) { - int parsed = JabberXmlParse(&xmlState, fileBuffer, tagend - fileBuffer + 1); + int parsed = TlenXmlParse(&xmlState, fileBuffer, tagend - fileBuffer + 1); if (parsed == 0) { continue; } @@ -153,7 +153,7 @@ static void TlenPsGetThread(void *ptr) { } } Netlib_CloseHandle(socket); - JabberLog(proto, "Picture received..."); + TlenLog(proto, "Picture received..."); LogPictureMessage(proto, item->ft->jid, item->ft->files[0], FALSE); } else { /* cannot connect to ps server */ @@ -163,33 +163,33 @@ static void TlenPsGetThread(void *ptr) { /* cannot create file */ } TlenP2PFreeFileTransfer(item->ft); - JabberListRemove(proto, LIST_PICTURE, item->jid); + TlenListRemove(proto, LIST_PICTURE, item->jid); mir_free(data); } -static void TlenPsGet(TlenProtocol *proto, JABBER_LIST_ITEM *item) { +static void TlenPsGet(TlenProtocol *proto, TLEN_LIST_ITEM *item) { TLENPSREQUESTTHREADDATA *threadData = (TLENPSREQUESTTHREADDATA *)mir_alloc(sizeof(TLENPSREQUESTTHREADDATA)); threadData->proto = proto; threadData->item = item; - JabberForkThread(TlenPsGetThread, 0, threadData); + TlenForkThread(TlenPsGetThread, 0, threadData); } void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { - JABBER_LIST_ITEM *item = NULL; + TLEN_LIST_ITEM *item = NULL; char *crc, *crc_c, *idt, *size, *from, *fromRaw, *rt; - from = JabberXmlGetAttrValue(node, "from"); - fromRaw = JabberLoginFromJID(from); - idt = JabberXmlGetAttrValue(node, "idt"); - size = JabberXmlGetAttrValue(node, "size"); - crc_c = JabberXmlGetAttrValue(node, "crc_c"); - crc = JabberXmlGetAttrValue(node, "crc"); - rt = JabberXmlGetAttrValue(node, "rt"); + from = TlenXmlGetAttrValue(node, "from"); + fromRaw = TlenLoginFromJID(from); + idt = TlenXmlGetAttrValue(node, "idt"); + size = TlenXmlGetAttrValue(node, "size"); + crc_c = TlenXmlGetAttrValue(node, "crc_c"); + crc = TlenXmlGetAttrValue(node, "crc"); + rt = TlenXmlGetAttrValue(node, "rt"); if (idt != NULL) { - item = JabberListGetItemPtr(proto, LIST_PICTURE, idt); + item = TlenListGetItemPtr(proto, LIST_PICTURE, idt); } if (item != NULL) { if (!strcmp(from, "ps")) { - char *st = JabberXmlGetAttrValue(node, "st"); + char *st = TlenXmlGetAttrValue(node, "st"); if (st != NULL) { item->ft->iqId = mir_strdup(st); item->ft->id2 = mir_strdup(rt); @@ -207,7 +207,7 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { /* crc_c = f, picture cached, no need to transfer again */ LogPictureMessage(proto, item->ft->jid, item->ft->files[0], TRUE); TlenP2PFreeFileTransfer(item->ft); - JabberListRemove(proto, LIST_PICTURE, idt); + TlenListRemove(proto, LIST_PICTURE, idt); } } else if (rt != NULL) { item->ft->id2 = mir_strdup(rt); @@ -219,7 +219,7 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { if (bAccept) { FILE* fp; char fileName[MAX_PATH]; - char *ext = JabberXmlGetAttrValue(node, "ext"); + char *ext = TlenXmlGetAttrValue(node, "ext"); char *tmpPath = Utils_ReplaceVars( "%miranda_userdata%" ); int tPathLen = mir_snprintf(fileName, MAX_PATH, "%s\\Images\\Tlen", tmpPath); long oldSize = 0, lSize = atol(size); @@ -237,16 +237,16 @@ void TlenProcessPic(XmlNode *node, TlenProtocol *proto) { fclose(fp); } if (oldSize != lSize) { - item = JabberListAdd(proto, LIST_PICTURE, idt); + item = TlenListAdd(proto, LIST_PICTURE, idt); item->ft = TlenFileCreateFT(proto, from); item->ft->files = (char **) mir_alloc(sizeof(char *)); item->ft->filesSize = (long *) mir_alloc(sizeof(long)); item->ft->files[0] = mir_strdup(fileName); item->ft->filesSize[0] = lSize; item->ft->fileTotalSize = item->ft->filesSize[0]; - JabberSend(proto, "", from, idt); + TlenSend(proto, "", from, idt); } else { - JabberSend(proto, "", from, idt); + TlenSend(proto, "", from, idt); LogPictureMessage(proto, from, fileName, FALSE); } } @@ -277,15 +277,15 @@ BOOL SendPicture(TlenProtocol *proto, HANDLE hContact) { fseek(fp, 0, SEEK_END); size = ftell(fp); if (size > 0 && size < 256*1024) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; mir_sha1_ctx sha; DWORD digest[5]; int i; char idStr[10]; char fileBuffer[2048]; - int id = JabberSerialNext(proto); + int id = TlenSerialNext(proto); mir_snprintf(idStr, sizeof(idStr), "%d", id); - item = JabberListAdd(proto, LIST_PICTURE, idStr); + item = TlenListAdd(proto, LIST_PICTURE, idStr); item->ft = TlenFileCreateFT(proto, jid); item->ft->files = (char **) mir_alloc(sizeof(char *)); item->ft->filesSize = (long *) mir_alloc(sizeof(long)); @@ -306,7 +306,7 @@ BOOL SendPicture(TlenProtocol *proto, HANDLE hContact) { } } mir_sha1_finish( &sha, (BYTE* )digest ); - JabberSend(proto, "", jid, + TlenSend(proto, "", jid, (int)htonl(digest[0]), (int)htonl(digest[1]), (int)htonl(digest[2]), (int)htonl(digest[3]), (int)htonl(digest[4]), idStr, item->ft->filesSize[0], "jpg"); } else { /* file too big */ diff --git a/protocols/Tlen/src/tlen_presence.cpp b/protocols/Tlen/src/tlen_presence.cpp index a896635c59..b83e29f146 100644 --- a/protocols/Tlen/src/tlen_presence.cpp +++ b/protocols/Tlen/src/tlen_presence.cpp @@ -28,32 +28,32 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) { HANDLE hContact; XmlNode *showNode, *statusNode; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char *from, *type, *nick, *show; int status, laststatus = ID_STATUS_OFFLINE; char *p; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { - if (JabberListExist(proto, LIST_CHATROOM, from)); //JabberGroupchatProcessPresence(node, userdata); + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { + if (TlenListExist(proto, LIST_CHATROOM, from)); //TlenGroupchatProcessPresence(node, userdata); else { - type = JabberXmlGetAttrValue(node, "type"); - item = JabberListGetItemPtr(proto, LIST_ROSTER, from); + type = TlenXmlGetAttrValue(node, "type"); + item = TlenListGetItemPtr(proto, LIST_ROSTER, from); if (item != NULL) { if (proto->tlenOptions.enableAvatars) { TlenProcessPresenceAvatar(proto, node, item); } } if (type == NULL || (!strcmp(type, "available"))) { - if ((nick=JabberLocalNickFromJID(from)) != NULL) { - if ((hContact=JabberHContactFromJID(proto, from)) == NULL) - hContact = JabberDBCreateContact(proto, from, nick, FALSE); - if (!JabberListExist(proto, LIST_ROSTER, from)) { - JabberLog(proto, "Receive presence online from %s (who is not in my roster)", from); - JabberListAdd(proto, LIST_ROSTER, from); + if ((nick=TlenLocalNickFromJID(from)) != NULL) { + if ((hContact=TlenHContactFromJID(proto, from)) == NULL) + hContact = TlenDBCreateContact(proto, from, nick, FALSE); + if (!TlenListExist(proto, LIST_ROSTER, from)) { + TlenLog(proto, "Receive presence online from %s (who is not in my roster)", from); + TlenListAdd(proto, LIST_ROSTER, from); } status = ID_STATUS_ONLINE; - if ((showNode=JabberXmlGetChild(node, "show")) != NULL) { + if ((showNode=TlenXmlGetChild(node, "show")) != NULL) { if ((show=showNode->text) != NULL) { if (!strcmp(show, "away")) status = ID_STATUS_AWAY; else if (!strcmp(show, "xa")) status = ID_STATUS_NA; @@ -66,12 +66,12 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) } } - statusNode = JabberXmlGetChild(node, "status"); + statusNode = TlenXmlGetChild(node, "status"); if (statusNode) - p = JabberTextDecode(statusNode->text); + p = TlenTextDecode(statusNode->text); else p = NULL; - JabberListAddResource(proto, LIST_ROSTER, from, status, statusNode?p:NULL); + TlenListAddResource(proto, LIST_ROSTER, from, status, statusNode?p:NULL); if (p) { db_set_s(hContact, "CList", "StatusMsg", p); mir_free(p); @@ -89,38 +89,38 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) } if (item != NULL) { if (!item->infoRequested) { - int iqId = JabberSerialNext(proto); + int iqId = TlenSerialNext(proto); item->infoRequested = TRUE; - JabberSend( proto, "", iqId, from); + TlenSend( proto, "", iqId, from); } if (proto->tlenOptions.enableVersion && !item->versionRequested) { item->versionRequested = TRUE; if (proto->m_iStatus != ID_STATUS_INVISIBLE) { - JabberSend( proto, "", from ); + TlenSend( proto, "", from ); } } } - JabberLog(proto, "%s (%s) online, set contact status to %d", nick, from, status); + TlenLog(proto, "%s (%s) online, set contact status to %d", nick, from, status); mir_free(nick); } } else if (!strcmp(type, "unavailable")) { - if (!JabberListExist(proto, LIST_ROSTER, from)) { - JabberLog(proto, "Receive presence offline from %s (who is not in my roster)", from); - JabberListAdd(proto, LIST_ROSTER, from); + if (!TlenListExist(proto, LIST_ROSTER, from)) { + TlenLog(proto, "Receive presence offline from %s (who is not in my roster)", from); + TlenListAdd(proto, LIST_ROSTER, from); } else { - JabberListRemoveResource(proto, LIST_ROSTER, from); + TlenListRemoveResource(proto, LIST_ROSTER, from); } status = ID_STATUS_OFFLINE; - statusNode = JabberXmlGetChild(node, "status"); + statusNode = TlenXmlGetChild(node, "status"); if (statusNode) { if (proto->tlenOptions.offlineAsInvisible) { status = ID_STATUS_INVISIBLE; } - p = JabberTextDecode(statusNode->text); - JabberListAddResource(proto, LIST_ROSTER, from, status, p); - if ((hContact=JabberHContactFromJID(proto, from)) != NULL) { + p = TlenTextDecode(statusNode->text); + TlenListAddResource(proto, LIST_ROSTER, from, status, p); + if ((hContact=TlenHContactFromJID(proto, from)) != NULL) { if (p) { db_set_s(hContact, "CList", "StatusMsg", p); } else { @@ -129,13 +129,13 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) } if (p) mir_free(p); } - if ((item=JabberListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) { + if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) { // Determine status to show for the contact based on the remaining resources item->status = status; item->versionRequested = FALSE; item->infoRequested = FALSE; } - if ((hContact=JabberHContactFromJID(proto, from)) != NULL) { + if ((hContact=TlenHContactFromJID(proto, from)) != NULL) { if (strchr(from, '@') != NULL || db_get_b(NULL, proto->m_szModuleName, "ShowTransport", TRUE) == TRUE) { if (db_get_w(hContact, proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != status) db_set_w(hContact, proto->m_szModuleName, "Status", (WORD) status); @@ -144,22 +144,22 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) item->isTyping = FALSE; CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, PROTOTYPE_CONTACTTYPING_OFF); } - JabberLog(proto, "%s offline, set contact status to %d", from, status); + TlenLog(proto, "%s offline, set contact status to %d", from, status); } } else if (!strcmp(type, "subscribe")) { if (strchr(from, '@') == NULL) { // automatically send authorization allowed to agent/transport - JabberSend(proto, "", from); + TlenSend(proto, "", from); } - else if ((nick=JabberNickFromJID(from)) != NULL) { - JabberLog(proto, "%s (%s) requests authorization", nick, from); - JabberDBAddAuthRequest(proto, from, nick); + else if ((nick=TlenNickFromJID(from)) != NULL) { + TlenLog(proto, "%s (%s) requests authorization", nick, from); + TlenDBAddAuthRequest(proto, from, nick); mir_free(nick); } } else if (!strcmp(type, "subscribed")) { - if ((item=JabberListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) { + if ((item=TlenListGetItemPtr(proto, LIST_ROSTER, from)) != NULL) { if (item->subscription == SUB_FROM) item->subscription = SUB_BOTH; else if (item->subscription == SUB_NONE) { item->subscription = SUB_TO; @@ -170,7 +170,7 @@ void TlenProcessPresence(XmlNode *node, TlenProtocol *proto) } } -static void JabberSendPresenceTo(TlenProtocol *proto, int status, char *to) +static void TlenSendPresenceTo(TlenProtocol *proto, int status, char *to) { char *showBody, *statusMsg, *presenceType; char *ptr = NULL; @@ -178,7 +178,7 @@ static void JabberSendPresenceTo(TlenProtocol *proto, int status, char *to) if (!proto->isOnline) return; // Send update for status (we won't handle ID_STATUS_OFFLINE here) - // Note: jabberModeMsg is already encoded using JabberTextEncode() + // Note: tlenModeMsg is already encoded using TlenTextEncode() EnterCriticalSection(&proto->modeMsgMutex); showBody = NULL; @@ -273,14 +273,14 @@ static void JabberSendPresenceTo(TlenProtocol *proto, int status, char *to) proto->m_iStatus = status; if (presenceType) { if (statusMsg) - JabberSend(proto, "%s", presenceType, statusMsg); + TlenSend(proto, "%s", presenceType, statusMsg); else - JabberSend(proto, "", presenceType); + TlenSend(proto, "", presenceType); } else { if (statusMsg) - JabberSend(proto, "%s%s", showBody, statusMsg); + TlenSend(proto, "%s%s", showBody, statusMsg); else - JabberSend(proto, "%s", showBody); + TlenSend(proto, "%s", showBody); } if (ptr) { mir_free(ptr); @@ -290,7 +290,7 @@ static void JabberSendPresenceTo(TlenProtocol *proto, int status, char *to) -void JabberSendPresence(TlenProtocol *proto, int statusIn) +void TlenSendPresence(TlenProtocol *proto, int statusIn) { int statusOut; switch (statusIn) { @@ -312,7 +312,7 @@ void JabberSendPresence(TlenProtocol *proto, int statusIn) statusOut = ID_STATUS_DND; break; } - JabberSendPresenceTo(proto, statusOut, NULL); + TlenSendPresenceTo(proto, statusOut, NULL); } diff --git a/protocols/Tlen/src/tlen_svc.cpp b/protocols/Tlen/src/tlen_svc.cpp index 01388e7074..6b9de79f63 100644 --- a/protocols/Tlen/src/tlen_svc.cpp +++ b/protocols/Tlen/src/tlen_svc.cpp @@ -61,11 +61,11 @@ int TlenRunSearch(TlenProtocol *proto) { if (!proto->isOnline) return 0; if (proto->searchQuery != NULL && proto->searchIndex < 10) { iqId = proto->searchID; - JabberIqAdd(proto, iqId, IQ_PROC_GETSEARCH, JabberIqResultSearch); + TlenIqAdd(proto, iqId, IQ_PROC_GETSEARCH, TlenIqResultSearch); if (proto->searchIndex == 0) { - JabberSend(proto, "%s", iqId, proto->searchQuery); + TlenSend(proto, "%s", iqId, proto->searchQuery); } else { - JabberSend(proto, "%s%d", iqId, proto->searchQuery, proto->searchIndex * TLEN_MAX_SEARCH_RESULTS_PER_PAGE); + TlenSend(proto, "%s%d", iqId, proto->searchQuery, proto->searchIndex * TLEN_MAX_SEARCH_RESULTS_PER_PAGE); } proto->searchIndex ++; } @@ -79,7 +79,7 @@ void TlenResetSearchQuery(TlenProtocol *proto) { } proto->searchQueryLen = 0; proto->searchIndex = 0; - proto->searchID = JabberSerialNext(proto); + proto->searchID = TlenSerialNext(proto); } HANDLE TlenProtocol::SearchBasic(const PROTOCHAR* id) @@ -89,10 +89,10 @@ HANDLE TlenProtocol::SearchBasic(const PROTOCHAR* id) if (!isOnline) return 0; if (id == NULL) return 0; char* id_A = mir_t2a(id); - if ((jid=JabberTextEncode(id_A)) != NULL) { + if ((jid=TlenTextEncode(id_A)) != NULL) { searchJID = mir_strdup(id_A); TlenResetSearchQuery(this); - JabberStringAppend(&searchQuery, &searchQueryLen, "%s", jid); + TlenStringAppend(&searchQuery, &searchQueryLen, "%s", jid); iqId = TlenRunSearch(this); mir_free(jid); } @@ -109,9 +109,9 @@ HANDLE TlenProtocol::SearchByEmail(const PROTOCHAR* email) if (email == NULL) return 0; char* email_A = mir_t2a(email); - if ((emailEnc=JabberTextEncode(email_A)) != NULL) { + if ((emailEnc=TlenTextEncode(email_A)) != NULL) { TlenResetSearchQuery(this); - JabberStringAppend(&searchQuery, &searchQueryLen, "%s", emailEnc); + TlenStringAppend(&searchQuery, &searchQueryLen, "%s", emailEnc); iqId = TlenRunSearch(this); mir_free(emailEnc); } @@ -134,20 +134,20 @@ HANDLE TlenProtocol::SearchByName(const PROTOCHAR* nickT, const PROTOCHAR* first TlenResetSearchQuery(this); if (nick != NULL && nick[0] != '\0') { - if ((p=JabberTextEncode(nick)) != NULL) { - JabberStringAppend(&searchQuery, &searchQueryLen, "%s", p); + if ((p=TlenTextEncode(nick)) != NULL) { + TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } } if (firstName != NULL && firstName[0] != '\0') { - if ((p=JabberTextEncode(firstName)) != NULL) { - JabberStringAppend(&searchQuery, &searchQueryLen, "%s", p); + if ((p=TlenTextEncode(firstName)) != NULL) { + TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } } if (lastName != NULL && lastName[0] != '\0') { - if ((p=JabberTextEncode(lastName)) != NULL) { - JabberStringAppend(&searchQuery, &searchQueryLen, "%s", p); + if ((p=TlenTextEncode(lastName)) != NULL) { + TlenStringAppend(&searchQuery, &searchQueryLen, "%s", p); mir_free(p); } } @@ -167,7 +167,7 @@ HWND TlenProtocol::SearchAdvanced(HWND owner) if (!isOnline) return 0; TlenResetSearchQuery(this); - iqId = JabberSerialNext(this); + iqId = TlenSerialNext(this); if ((searchQuery = TlenAdvSearchCreateQuery(owner, iqId)) != NULL) { iqId = TlenRunSearch(this); } @@ -180,13 +180,13 @@ static HANDLE AddToListByJID(TlenProtocol *proto, const char *newJid, DWORD flag HANDLE hContact; char *jid, *nick; - if ((hContact=JabberHContactFromJID(proto, newJid)) == NULL) { + if ((hContact=TlenHContactFromJID(proto, newJid)) == NULL) { // not already there: add jid = mir_strdup(newJid); _strlwr(jid); hContact = (HANDLE) CallService(MS_DB_CONTACT_ADD, 0, 0); CallService(MS_PROTO_ADDTOCONTACT, (WPARAM) hContact, (LPARAM) proto->m_szModuleName); db_set_s(hContact, proto->m_szModuleName, "jid", jid); - if ((nick=JabberNickFromJID(newJid)) == NULL) + if ((nick=TlenNickFromJID(newJid)) == NULL) nick = mir_strdup(newJid); db_set_s(hContact, "CList", "MyHandle", nick); mir_free(nick); @@ -217,8 +217,8 @@ static HANDLE AddToListByJID(TlenProtocol *proto, const char *newJid, DWORD flag HANDLE TlenProtocol::AddToList(int flags, PROTOSEARCHRESULT *psr) { HANDLE hContact; - JABBER_SEARCH_RESULT *jsr = (JABBER_SEARCH_RESULT*)psr; - if (jsr->hdr.cbSize != sizeof(JABBER_SEARCH_RESULT)) + TLEN_SEARCH_RESULT *jsr = (TLEN_SEARCH_RESULT*)psr; + if (jsr->hdr.cbSize != sizeof(TLEN_SEARCH_RESULT)) return (int) NULL; hContact = AddToListByJID(this, jsr->jid, flags); // wParam is flag e.g. PALF_TEMPORARY return hContact; @@ -241,9 +241,9 @@ HANDLE TlenProtocol::AddToListByEvent( int flags, int iContact, HANDLE hDbEvent } /* - // EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Jabber) - // EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Jabber) - // Jabber will only handle the case of EVENTTYPE_AUTHREQUEST + // EVENTTYPE_CONTACTS is when adding from when we receive contact list (not used in Tlen) + // EVENTTYPE_ADDED is when adding from when we receive "You are added" (also not used in Tlen) + // Tlen will only handle the case of EVENTTYPE_AUTHREQUEST // EVENTTYPE_AUTHREQUEST is when adding from the authorization request dialog */ @@ -290,18 +290,18 @@ int TlenProtocol::Authorize(HANDLE hDbEvent) char *lastName = firstName + strlen(firstName) + 1; char *jid = lastName + strlen(lastName) + 1; - JabberSend(this, "", jid); + TlenSend(this, "", jid); // Automatically add this user to my roster if option is enabled if (db_get_b(NULL, m_szModuleName, "AutoAdd", TRUE) == TRUE) { HANDLE hContact; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; - if ((item=JabberListGetItemPtr(this, LIST_ROSTER, jid)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { - JabberLog(this, "Try adding contact automatically jid=%s", jid); + if ((item=TlenListGetItemPtr(this, LIST_ROSTER, jid)) == NULL || (item->subscription != SUB_BOTH && item->subscription != SUB_TO)) { + TlenLog(this, "Try adding contact automatically jid=%s", jid); if ((hContact=AddToListByJID(this, jid, 0)) != NULL) { // Trigger actual add by removing the "NotOnList" added by AddToListByJID() - // See AddToListByJID() and JabberDbSettingChanged(). + // See AddToListByJID() and TlenDbSettingChanged(). db_unset(hContact, "CList", "NotOnList"); } } @@ -339,8 +339,8 @@ int TlenProtocol::AuthDeny(HANDLE hDbEvent, const PROTOCHAR* szReason) char *lastName = firstName + strlen(firstName) + 1; char *jid = lastName + strlen(lastName) + 1; - JabberSend(this, "", jid); - JabberSend(this, "", jid); + TlenSend(this, "", jid); + TlenSend(this, "", jid); mir_free(dbei.pBlob); return 0; } @@ -359,7 +359,7 @@ static void TlenConnect(TlenProtocol *proto, int initialStatus) oldStatus = proto->m_iStatus; proto->m_iStatus = ID_STATUS_CONNECTING; ProtoBroadcastAck(proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, proto->m_iStatus); - thread->hThread = (HANDLE) JabberForkThread((void (__cdecl *)(void*))JabberServerThread, 0, thread); + thread->hThread = (HANDLE) TlenForkThread((void (__cdecl *)(void*))TlenServerThread, 0, thread); } } @@ -373,7 +373,7 @@ int TlenProtocol::SetStatus(int iNewStatus) if (iNewStatus == ID_STATUS_OFFLINE) { if (threadData) { if (isConnected) { - JabberSendPresence(this, ID_STATUS_OFFLINE); + TlenSendPresence(this, ID_STATUS_OFFLINE); } // TODO bug? s = proto; @@ -382,7 +382,7 @@ int TlenProtocol::SetStatus(int iNewStatus) threadData = NULL; if (isConnected) { Sleep(200); -// JabberSend(s, ""); +// TlenSend(s, ""); // Force closing connection isConnected = FALSE; isOnline = FALSE; @@ -404,7 +404,7 @@ int TlenProtocol::SetStatus(int iNewStatus) // change status oldStatus = m_iStatus; // send presence update - JabberSendPresence(this, iNewStatus); + TlenSendPresence(this, iNewStatus); ProtoBroadcastAck(NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, m_iStatus); } } @@ -421,9 +421,9 @@ int TlenProtocol::SetAwayMsg(int iStatus, const PROTOCHAR* msg) char **szMsg; char *newModeMsg; - JabberLog(this, "SetAwayMsg called, wParam=%d lParam=%s", iStatus, msg); + TlenLog(this, "SetAwayMsg called, wParam=%d lParam=%s", iStatus, msg); - newModeMsg = JabberTextEncode(mir_t2a(msg)); //TODO TCHAR + newModeMsg = TlenTextEncode(mir_t2a(msg)); //TODO TCHAR EnterCriticalSection(&modeMsgMutex); @@ -465,7 +465,7 @@ int TlenProtocol::SetAwayMsg(int iStatus, const PROTOCHAR* msg) *szMsg = newModeMsg; // Send a presence update if needed if (iStatus == m_iStatus) { - JabberSendPresence(this, m_iStatus); + TlenSendPresence(this, m_iStatus); } } @@ -481,16 +481,16 @@ int TlenProtocol::GetInfo(HANDLE hContact, int infoType) if (!isOnline) return 1; if (hContact == NULL) { - iqId = JabberSerialNext(this); - JabberIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); - JabberSend(this, "", iqId); + iqId = TlenSerialNext(this); + TlenIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); + TlenSend(this, "", iqId); } else { if (db_get(hContact, m_szModuleName, "jid", &dbv)) return 1; - if ((nick=JabberNickFromJID(dbv.pszVal)) != NULL) { - if ((pNick=JabberTextEncode(nick)) != NULL) { - iqId = JabberSerialNext(this); - JabberIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); - JabberSend(this, "%s", iqId, pNick); + if ((nick=TlenNickFromJID(dbv.pszVal)) != NULL) { + if ((pNick=TlenTextEncode(nick)) != NULL) { + iqId = TlenSerialNext(this); + TlenIqAdd(this, iqId, IQ_PROC_NONE, TlenIqResultVcard); + TlenSend(this, "%s", iqId, pNick); mir_free(pNick); } mir_free(nick); @@ -517,17 +517,17 @@ int TlenProtocol::SetApparentMode(HANDLE hContact, int mode) switch (mode) { case ID_STATUS_ONLINE: if (m_iStatus == ID_STATUS_INVISIBLE || oldMode == ID_STATUS_OFFLINE) - JabberSend(this, "available", jid); + TlenSend(this, "available", jid); break; case ID_STATUS_OFFLINE: if (m_iStatus != ID_STATUS_INVISIBLE || oldMode == ID_STATUS_ONLINE) - JabberSend(this, "", jid); + TlenSend(this, "", jid); break; case 0: if (oldMode == ID_STATUS_ONLINE && m_iStatus == ID_STATUS_INVISIBLE) - JabberSend(this, "", jid); + TlenSend(this, "", jid); else if (oldMode == ID_STATUS_OFFLINE && m_iStatus != ID_STATUS_INVISIBLE) - JabberSend(this, "available", jid); + TlenSend(this, "available", jid); break; } db_free(&dbv); @@ -548,7 +548,7 @@ struct SENDACKTHREADDATA int msgid; }; -static void __cdecl JabberSendMessageAckThread(void *ptr) +static void __cdecl TlenSendMessageAckThread(void *ptr) { SENDACKTHREADDATA *data = (SENDACKTHREADDATA *)ptr; SleepEx(10, TRUE); @@ -567,10 +567,10 @@ static void __cdecl TlenSendMessageFailedThread(void *ptr) static void __cdecl TlenGetAwayMsgThread(void *ptr) { DBVARIANT dbv; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; SENDACKTHREADDATA *data = (SENDACKTHREADDATA *)ptr; if (!db_get(data->hContact, data->proto->m_szModuleName, "jid", &dbv)) { - if ((item=JabberListGetItemPtr(data->proto, LIST_ROSTER, dbv.pszVal)) != NULL) { + if ((item=TlenListGetItemPtr(data->proto, LIST_ROSTER, dbv.pszVal)) != NULL) { db_free(&dbv); ProtoBroadcastAck(data->proto->m_szModuleName, data->hContact, ACKTYPE_AWAYMSG, ACKRESULT_SUCCESS, (HANDLE)1, item->statusMessage==NULL ? (LPARAM)NULL : (LPARAM)(TCHAR*)_A2T(item->statusMessage)); @@ -587,7 +587,7 @@ INT_PTR TlenProtocol::SendAlert(WPARAM wParam, LPARAM lParam) HANDLE hContact = ( HANDLE )wParam; DBVARIANT dbv; if (isOnline && !db_get(hContact, m_szModuleName, "jid", &dbv)) { - JabberSend(this, "", dbv.pszVal); + TlenSend(this, "", dbv.pszVal); db_free(&dbv); } @@ -598,11 +598,11 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW) { DBVARIANT dbv; char *msgEnc; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char msgType[16]; if (!isOnline || db_get(hContact, m_szModuleName, "jid", &dbv)) { - JabberForkThread(TlenSendMessageFailedThread, 0, new SENDACKTHREADDATA(this, hContact, 2)); + TlenForkThread(TlenSendMessageFailedThread, 0, new SENDACKTHREADDATA(this, hContact, 2)); return 2; } @@ -615,19 +615,19 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW) msg = mir_strdup(msgRAW); - int id = JabberSerialNext(this); + int id = TlenSerialNext(this); if (!strcmp(msg, "")) { - JabberSend(this, "", dbv.pszVal); - JabberForkThread(JabberSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); + TlenSend(this, "", dbv.pszVal); + TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); } else if (!strcmp(msg, "")) { - JabberSend(this, "", dbv.pszVal, "pic", 0x757f044, id); - JabberForkThread(JabberSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); + TlenSend(this, "", dbv.pszVal, "pic", 0x757f044, id); + TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); } else { - if ((msgEnc=JabberTextEncode(msg)) != NULL) { - if (JabberListExist(this, LIST_CHATROOM, dbv.pszVal) && strchr(dbv.pszVal, '/') == NULL) + if ((msgEnc=TlenTextEncode(msg)) != NULL) { + if (TlenListExist(this, LIST_CHATROOM, dbv.pszVal) && strchr(dbv.pszVal, '/') == NULL) strcpy(msgType, "groupchat"); else if (db_get_b(hContact, m_szModuleName, "bChat", FALSE)) strcpy(msgType, "privchat"); @@ -639,18 +639,18 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW) tdata->proto = this; tdata->hContact = hContact; if (!strcmp(msgType, "groupchat")) - JabberSend(this, "%s", dbv.pszVal, msgType, msgEnc); + TlenSend(this, "%s", dbv.pszVal, msgType, msgEnc); else if (!strcmp(msgType, "privchat")) - JabberSend(this, "%s", dbv.pszVal, msgEnc); + TlenSend(this, "%s", dbv.pszVal, msgEnc); else - JabberSend(this, "%s", dbv.pszVal, msgType, id, msgEnc); + TlenSend(this, "%s", dbv.pszVal, msgType, id, msgEnc); - JabberForkThread(JabberSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); + TlenForkThread(TlenSendMessageAckThread, 0, new SENDACKTHREADDATA(this, hContact, id)); } else { - if ((item=JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) + if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) item->idMsgAckPending = id; - JabberSend(this, "%s", dbv.pszVal, msgType, id, msgEnc); + TlenSend(this, "%s", dbv.pszVal, msgType, id, msgEnc); } } mir_free(msgEnc); @@ -662,20 +662,20 @@ int TlenProtocol::SendMsg(HANDLE hContact, int flags, const char* msgRAW) } ///////////////////////////////////////////////////////////////////////////////////////// -// JabberGetAvatarInfo - retrieves the avatar info +// TlenGetAvatarInfo - retrieves the avatar info INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam) { BOOL downloadingAvatar = FALSE; char *avatarHash = NULL; - JABBER_LIST_ITEM *item = NULL; + TLEN_LIST_ITEM *item = NULL; DBVARIANT dbv; PROTO_AVATAR_INFORMATIONT* AI = ( PROTO_AVATAR_INFORMATIONT* )lParam; if (!tlenOptions.enableAvatars) return GAIR_NOAVATAR; if (AI->hContact != NULL) { if (!db_get(AI->hContact, m_szModuleName, "jid", &dbv)) { - item = JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal); + item = TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal); db_free(&dbv); if (item != NULL) { downloadingAvatar = item->newAvatarDownloading; @@ -705,7 +705,7 @@ INT_PTR TlenProtocol::GetAvatarInfo(WPARAM wParam, LPARAM lParam) HANDLE TlenProtocol::GetAwayMsg(HANDLE hContact) { SENDACKTHREADDATA *tdata = new SENDACKTHREADDATA(this, hContact, 0); - JabberForkThread((void (__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata); + TlenForkThread((void (__cdecl *)(void*))TlenGetAwayMsgThread, 0, (void*)tdata); return (HANDLE)1; } @@ -722,21 +722,21 @@ int TlenProtocol::SendAwayMsg(HANDLE hContact, HANDLE hProcess, const char* msg) HANDLE TlenProtocol::FileAllow(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* szPath) { TLEN_FILE_TRANSFER *ft; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char *nick; if (!isOnline) return 0; ft = (TLEN_FILE_TRANSFER *) hTransfer; ft->szSavePath = mir_strdup(mir_t2a(szPath)); //TODO convert to PROTOCHAR* - if ((item=JabberListAdd(this, LIST_FILE, ft->iqId)) != NULL) { + if ((item=TlenListAdd(this, LIST_FILE, ft->iqId)) != NULL) { item->ft = ft; } - nick = JabberNickFromJID(ft->jid); + nick = TlenNickFromJID(ft->jid); if (ft->newP2P) { - JabberSend(this, "", ft->jid, ft->jid, ft->iqId); + TlenSend(this, "", ft->jid, ft->jid, ft->iqId); } else { - JabberSend(this, "", nick, ft->iqId); + TlenSend(this, "", nick, ft->iqId); } mir_free(nick); return (HANDLE)hTransfer; @@ -750,11 +750,11 @@ int TlenProtocol::FileDeny(HANDLE hContact, HANDLE hTransfer, const PROTOCHAR* s if (!isOnline) return 1; ft = (TLEN_FILE_TRANSFER *) hTransfer; - nick = JabberNickFromJID(ft->jid); + nick = TlenNickFromJID(ft->jid); if (ft->newP2P) { - JabberSend(this, "", ft->iqId, nick);\ + TlenSend(this, "", ft->iqId, nick);\ } else { - JabberSend(this, "", ft->iqId, nick);\ + TlenSend(this, "", ft->iqId, nick);\ } mir_free(nick); TlenP2PFreeFileTransfer(ft); @@ -768,7 +768,7 @@ int TlenProtocol::FileResume(HANDLE hTransfer, int* action, const PROTOCHAR** sz int TlenProtocol::FileCancel(HANDLE hContact, HANDLE hTransfer) { TLEN_FILE_TRANSFER *ft = (TLEN_FILE_TRANSFER *) hTransfer; - JabberLog(this, "Invoking FileCancel()"); + TlenLog(this, "Invoking FileCancel()"); if (ft->s != NULL) { ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); @@ -791,7 +791,7 @@ HANDLE TlenProtocol::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, P struct _stat statbuf; DBVARIANT dbv; char *nick, *p, idStr[10]; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; int id; if (!isOnline) return 0; @@ -805,7 +805,7 @@ HANDLE TlenProtocol::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, P for (i=j=0; ifileCount; i++) { char* ppszFiles_i_A = mir_t2a(ppszFiles[i]); if (_stat(ppszFiles_i_A, &statbuf)) - JabberLog(this, "'%s' is an invalid filename", ppszFiles[i]); + TlenLog(this, "'%s' is an invalid filename", ppszFiles[i]); else { ft->filesSize[j] = statbuf.st_size; ft->files[j++] = mir_strdup(ppszFiles_i_A); @@ -819,14 +819,14 @@ HANDLE TlenProtocol::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, P ft->currentFile = 0; db_free(&dbv); - id = JabberSerialNext(this); + id = TlenSerialNext(this); mir_snprintf(idStr, sizeof(idStr), "%d", id); - if ((item=JabberListAdd(this, LIST_FILE, idStr)) != NULL) { + if ((item=TlenListAdd(this, LIST_FILE, idStr)) != NULL) { ft->iqId = mir_strdup(idStr); - nick = JabberNickFromJID(ft->jid); + nick = TlenNickFromJID(ft->jid); item->ft = ft; if (tlenOptions.useNewP2P) { - JabberSend(this, "", + TlenSend(this, "", ft->jid, ft->jid, idStr, ft->fileCount, ft->allFileTotalSize, ft->fileCount); ft->newP2P = TRUE; @@ -838,12 +838,12 @@ HANDLE TlenProtocol::SendFile(HANDLE hContact, const PROTOCHAR* szDescription, P } else { p = ppszFiles_0_A; } - p = JabberTextEncode(p); - JabberSend(this, "", nick, p, idStr, ft->allFileTotalSize); + p = TlenTextEncode(p); + TlenSend(this, "", nick, p, idStr, ft->allFileTotalSize); mir_free(ppszFiles[0]); mir_free(p); } else { - JabberSend(this, "", nick, idStr, ft->fileCount, ft->allFileTotalSize); + TlenSend(this, "", nick, idStr, ft->fileCount, ft->allFileTotalSize); } } mir_free(nick); @@ -886,7 +886,7 @@ static char* settingToChar( DBCONTACTWRITESETTING* cws ) return NULL; } -int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) +int TlenProtocol::TlenDbSettingChanged(WPARAM wParam, LPARAM lParam) { DBCONTACTWRITESETTING *cws = (DBCONTACTWRITESETTING *) lParam; // no action for hContact == NULL or when offline @@ -896,7 +896,7 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) if (!strcmp(cws->szModule, "CList")) { HANDLE hContact; DBVARIANT dbv; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char *szProto, *nick, *jid, *group; hContact = (HANDLE) wParam; @@ -905,30 +905,30 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) // A contact's group is changed if (!strcmp(cws->szSetting, "Group")) { if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - if ((item=JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) { + if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) { db_free(&dbv); if (!db_get(hContact, "CList", "MyHandle", &dbv)) { - nick = JabberTextEncode(dbv.pszVal); + nick = TlenTextEncode(dbv.pszVal); db_free(&dbv); } else if (!db_get(hContact, this->m_szModuleName, "Nick", &dbv)) { - nick = JabberTextEncode(dbv.pszVal); + nick = TlenTextEncode(dbv.pszVal); db_free(&dbv); } - else nick = JabberNickFromJID(item->jid); + else nick = TlenNickFromJID(item->jid); if (nick != NULL) { // Note: we need to compare with item->group to prevent infinite loop if (cws->value.type == DBVT_DELETED && item->group != NULL) { - JabberLog(this, "Group set to nothing"); - JabberSend(this, "", nick, item->jid); + TlenLog(this, "Group set to nothing"); + TlenSend(this, "", nick, item->jid); } else if (cws->value.pszVal != NULL) { char *newGroup = settingToChar(cws); if (item->group == NULL || strcmp(newGroup, item->group)) { - JabberLog(this, "Group set to %s", newGroup); + TlenLog(this, "Group set to %s", newGroup); if ((group=TlenGroupEncode(newGroup)) != NULL) { - JabberSend(this, "%s", nick, item->jid, group); + TlenSend(this, "%s", nick, item->jid, group); mir_free(group); } } @@ -952,7 +952,7 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { jid = dbv.pszVal; - if ((item=JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) { + if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL) { if (cws->value.type == DBVT_DELETED) { newNick = mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, GCDNF_NOMYHANDLE)); } else if (cws->value.pszVal != NULL) { @@ -962,13 +962,13 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) } // Note: we need to compare with item->nick to prevent infinite loop if (newNick != NULL && (item->nick == NULL || (item->nick != NULL && strcmp(item->nick, newNick)))) { - if ((nick=JabberTextEncode(newNick)) != NULL) { - JabberLog(this, "Nick set to %s", newNick); + if ((nick=TlenTextEncode(newNick)) != NULL) { + TlenLog(this, "Nick set to %s", newNick); if (item->group != NULL && (group=TlenGroupEncode(item->group)) != NULL) { - JabberSend(this, "%s", nick, jid, group); + TlenSend(this, "%s", nick, jid, group); mir_free(group); } else { - JabberSend(this, "", nick, jid); + TlenSend(this, "", nick, jid); } mir_free(nick); } @@ -986,27 +986,27 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { jid = mir_strdup(dbv.pszVal); db_free(&dbv); - JabberLog(this, "Add %s permanently to list", jid); + TlenLog(this, "Add %s permanently to list", jid); if (!db_get(hContact, "CList", "MyHandle", &dbv)) { - nick = JabberTextEncode(dbv.pszVal); //Utf8Encode + nick = TlenTextEncode(dbv.pszVal); //Utf8Encode db_free(&dbv); } else { - nick = JabberNickFromJID(jid); + nick = TlenNickFromJID(jid); } if (nick != NULL) { - JabberLog(this, "jid=%s nick=%s", jid, nick); + TlenLog(this, "jid=%s nick=%s", jid, nick); if (!db_get(hContact, "CList", "Group", &dbv)) { if ((pGroup=TlenGroupEncode(dbv.pszVal)) != NULL) { - JabberSend(this, "%s", nick, jid, pGroup); - JabberSend(this, "", jid); + TlenSend(this, "%s", nick, jid, pGroup); + TlenSend(this, "", jid); mir_free(pGroup); } db_free(&dbv); } else { - JabberSend(this, "", nick, jid); - JabberSend(this, "", jid); + TlenSend(this, "", nick, jid); + TlenSend(this, "", jid); } mir_free(nick); db_unset(hContact, "CList", "Hidden"); @@ -1020,7 +1020,7 @@ int TlenProtocol::JabberDbSettingChanged(WPARAM wParam, LPARAM lParam) return 0; } -int TlenProtocol::JabberContactDeleted(WPARAM wParam, LPARAM lParam) +int TlenProtocol::TlenContactDeleted(WPARAM wParam, LPARAM lParam) { if (!isOnline) // should never happen return 0; @@ -1040,8 +1040,8 @@ int TlenProtocol::JabberContactDeleted(WPARAM wParam, LPARAM lParam) } // Remove from roster, server also handles the presence unsubscription process. - if (JabberListExist(this, LIST_ROSTER, jid)) - JabberSend(this, "", jid); + if (TlenListExist(this, LIST_ROSTER, jid)) + TlenSend(this, "", jid); db_free(&dbv); } @@ -1051,17 +1051,17 @@ int TlenProtocol::JabberContactDeleted(WPARAM wParam, LPARAM lParam) int TlenProtocol::UserIsTyping(HANDLE hContact, int type) { DBVARIANT dbv; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; if (!isOnline) return 0; if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { - if ((item=JabberListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL /*&& item->wantComposingEvent == TRUE*/) { + if ((item=TlenListGetItemPtr(this, LIST_ROSTER, dbv.pszVal)) != NULL /*&& item->wantComposingEvent == TRUE*/) { switch (type) { case PROTOTYPE_SELFTYPING_OFF: - JabberSend(this, "", dbv.pszVal); + TlenSend(this, "", dbv.pszVal); break; case PROTOTYPE_SELFTYPING_ON: - JabberSend(this, "", dbv.pszVal); + TlenSend(this, "", dbv.pszVal); break; } } @@ -1239,8 +1239,8 @@ TlenProtocol::TlenProtocol( const char *aProtoName, const TCHAR *aUserName) : hTlenNudge = CreateProtoEvent("/Nudge"); HookProtoEvent(ME_OPT_INITIALISE, &TlenProtocol::OptionsInit); - HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &TlenProtocol::JabberDbSettingChanged); - HookProtoEvent(ME_DB_CONTACT_DELETED, &TlenProtocol::JabberContactDeleted); + HookProtoEvent(ME_DB_CONTACT_SETTINGCHANGED, &TlenProtocol::TlenDbSettingChanged); + HookProtoEvent(ME_DB_CONTACT_DELETED, &TlenProtocol::TlenContactDeleted); HookProtoEvent(ME_CLIST_PREBUILDCONTACTMENU, &TlenProtocol::PrebuildContactMenu); HookProtoEvent(ME_SYSTEM_PRESHUTDOWN, &TlenProtocol::PreShutdown); @@ -1257,10 +1257,10 @@ TlenProtocol::TlenProtocol( const char *aProtoName, const TCHAR *aUserName) : TlenLoadOptions(this); - JabberWsInit(this); - JabberSerialInit(this); - JabberIqInit(this); - JabberListInit(this); + TlenWsInit(this); + TlenSerialInit(this); + TlenIqInit(this); + TlenListInit(this); initMenuItems(); } @@ -1272,12 +1272,12 @@ TlenProtocol::~TlenProtocol() TlenFileCancelAll(this); if (hTlenNudge) DestroyHookableEvent(hTlenNudge); - JabberListUninit(this); - JabberIqUninit(this); - JabberSerialUninit(this); + TlenListUninit(this); + TlenIqUninit(this); + TlenSerialUninit(this); DeleteCriticalSection(&modeMsgMutex); DeleteCriticalSection(&csSend); - JabberWsUninit(this); + TlenWsUninit(this); mir_free(modeMsgs.szOnline); mir_free(modeMsgs.szAway); diff --git a/protocols/Tlen/src/tlen_thread.cpp b/protocols/Tlen/src/tlen_thread.cpp index 4e26a83193..d9e7c188f1 100644 --- a/protocols/Tlen/src/tlen_thread.cpp +++ b/protocols/Tlen/src/tlen_thread.cpp @@ -43,12 +43,12 @@ extern void __cdecl TlenProcessP2P(XmlNode *node, ThreadData *info); //static void __cdecl TlenProcessInvitation(struct ThreadData *info); -static void __cdecl JabberKeepAliveThread(void *ptr); -static void JabberProcessStreamOpening(XmlNode *node, ThreadData *info); -static void JabberProcessStreamClosing(XmlNode *node, ThreadData *info); -static void JabberProcessProtocol(XmlNode *node, ThreadData *info); -static void JabberProcessMessage(XmlNode *node, ThreadData *info); -static void JabberProcessIq(XmlNode *node, ThreadData *info); +static void __cdecl TlenKeepAliveThread(void *ptr); +static void TlenProcessStreamOpening(XmlNode *node, ThreadData *info); +static void TlenProcessStreamClosing(XmlNode *node, ThreadData *info); +static void TlenProcessProtocol(XmlNode *node, ThreadData *info); +static void TlenProcessMessage(XmlNode *node, ThreadData *info); +static void TlenProcessIq(XmlNode *node, ThreadData *info); static void TlenProcessW(XmlNode *node, ThreadData *info); static void TlenProcessM(XmlNode *node, ThreadData *info); static void TlenProcessN(XmlNode *node, ThreadData *info); @@ -57,7 +57,7 @@ static void TlenProcessV(XmlNode *node, ThreadData *info); static void TlenProcessAvatar(XmlNode* node, ThreadData *info); static void TlenProcessCipher(XmlNode *node, ThreadData *info); -static VOID NTAPI JabberDummyApcFunc(ULONG_PTR param) +static VOID NTAPI TlenDummyApcFunc(ULONG_PTR param) { return; } @@ -65,7 +65,7 @@ static VOID NTAPI JabberDummyApcFunc(ULONG_PTR param) static char onlinePassword[128]; static HANDLE hEventPasswdDlg; -static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) +static INT_PTR CALLBACK TlenPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) { char text[128]; @@ -94,12 +94,12 @@ static INT_PTR CALLBACK JabberPasswordDlgProc(HWND hwndDlg, UINT msg, WPARAM wPa return FALSE; } -static VOID NTAPI JabberPasswordCreateDialogApcProc(ULONG_PTR param) +static VOID NTAPI TlenPasswordCreateDialogApcProc(ULONG_PTR param) { - CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, JabberPasswordDlgProc, (LPARAM) param); + CreateDialogParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, TlenPasswordDlgProc, (LPARAM) param); } -void __cdecl JabberServerThread(ThreadData *info) +void __cdecl TlenServerThread(ThreadData *info) { DBVARIANT dbv; char jidStr[128]; @@ -107,13 +107,13 @@ void __cdecl JabberServerThread(ThreadData *info) char *buffer; int datalen; XmlState xmlState; - int jabberNetworkBufferSize; + int tlenNetworkBufferSize; int oldStatus = ID_STATUS_OFFLINE; int reconnectMaxTime; int numRetry; int reconnectTime; int loginErr = 0; - JabberLog(info->proto, "Thread started"); + TlenLog(info->proto, "Thread started"); // Normal server connection, we will fetch all connection parameters // e.g. username, password, etc. from the database. @@ -123,8 +123,8 @@ void __cdecl JabberServerThread(ThreadData *info) // Make APC call to the main thread. This will immediately wake the thread up // in case it is asleep in the reconnect loop so that it will immediately // reconnect. - QueueUserAPC(JabberDummyApcFunc, info->proto->threadData->hThread, 0); - JabberLog(info->proto, "Thread ended, another normal thread is running"); + QueueUserAPC(TlenDummyApcFunc, info->proto->threadData->hThread, 0); + TlenLog(info->proto, "Thread ended, another normal thread is running"); mir_free(info); return; } @@ -139,7 +139,7 @@ void __cdecl JabberServerThread(ThreadData *info) db_free(&dbv); } else { - JabberLog(info->proto, "Thread ended, login name is not configured"); + TlenLog(info->proto, "Thread ended, login name is not configured"); loginErr = LOGINERR_BADUSERID; } @@ -151,7 +151,7 @@ void __cdecl JabberServerThread(ThreadData *info) db_set_s(NULL, info->proto->m_szModuleName, "LoginServer", info->server); db_free(&dbv); } else { - JabberLog(info->proto, "Thread ended, login server is not configured"); + TlenLog(info->proto, "Thread ended, login server is not configured"); loginErr = LOGINERR_NONETWORK; } } @@ -164,15 +164,15 @@ void __cdecl JabberServerThread(ThreadData *info) // Should be better with modeless. onlinePassword[0] = (char) -1; hEventPasswdDlg = CreateEvent(NULL, FALSE, FALSE, NULL); - QueueUserAPC(JabberPasswordCreateDialogApcProc, hMainThread, (DWORD) jidStr); + QueueUserAPC(TlenPasswordCreateDialogApcProc, hMainThread, (DWORD) jidStr); WaitForSingleObject(hEventPasswdDlg, INFINITE); CloseHandle(hEventPasswdDlg); - //if ((p=(char *)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, JabberPasswordDlgProc, (LPARAM) jidStr)) != onlinePassword) { + //if ((p=(char *)DialogBoxParam(hInst, MAKEINTRESOURCE(IDD_PASSWORD), NULL, TlenPasswordDlgProc, (LPARAM) jidStr)) != onlinePassword) { if (onlinePassword[0] != (char) -1) { strncpy(info->password, onlinePassword, sizeof(info->password)); info->password[sizeof(info->password)-1] = '\0'; } else { - JabberLog(info->proto, "Thread ended, password request dialog was canceled"); + TlenLog(info->proto, "Thread ended, password request dialog was canceled"); loginErr = LOGINERR_BADUSERID; } } else { @@ -182,15 +182,15 @@ void __cdecl JabberServerThread(ThreadData *info) info->password[sizeof(info->password)-1] = '\0'; db_free(&dbv); } else { - JabberLog(info->proto, "Thread ended, password is not configured"); + TlenLog(info->proto, "Thread ended, password is not configured"); loginErr = LOGINERR_BADUSERID; } } } - jabberNetworkBufferSize = 2048; - if ((buffer=(char *) mir_alloc(jabberNetworkBufferSize+1)) == NULL) { // +1 is for '\0' when debug logging this buffer - JabberLog(info->proto, "Thread ended, network buffer cannot be allocated"); + tlenNetworkBufferSize = 2048; + if ((buffer=(char *) mir_alloc(tlenNetworkBufferSize+1)) == NULL) { // +1 is for '\0' when debug logging this buffer + TlenLog(info->proto, "Thread ended, network buffer cannot be allocated"); loginErr = LOGINERR_NONETWORK; } @@ -220,7 +220,7 @@ void __cdecl JabberServerThread(ThreadData *info) else connectHost = info->server; - JabberLog(info->proto, "Thread server='%s' port='%d'", connectHost, info->port); + TlenLog(info->proto, "Thread server='%s' port='%d'", connectHost, info->port); if (!db_get(NULL, info->proto->m_szModuleName, "AvatarHash", &dbv)) { @@ -235,9 +235,9 @@ void __cdecl JabberServerThread(ThreadData *info) for (;;) { // Reconnect loop - info->s = JabberWsConnect(info->proto, connectHost, info->port); + info->s = TlenWsConnect(info->proto, connectHost, info->port); if (info->s == NULL) { - JabberLog(info->proto, "Connection failed (%d)", WSAGetLastError()); + TlenLog(info->proto, "Connection failed (%d)", WSAGetLastError()); if (info->proto->threadData == info) { oldStatus = info->proto->m_iStatus; info->proto->m_iStatus = ID_STATUS_OFFLINE; @@ -245,12 +245,12 @@ void __cdecl JabberServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus); if (info->proto->tlenOptions.reconnect == TRUE) { reconnectTime = rand() % reconnectMaxTime; - JabberLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); + TlenLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); SleepEx(reconnectTime * 1000, TRUE); if (reconnectMaxTime < 10*60) // Maximum is 10 minutes reconnectMaxTime *= 2; - if (info->proto->threadData == info) { // Make sure this is still the active thread for the main Jabber connection - JabberLog(info->proto, "Reconnecting to the network..."); + if (info->proto->threadData == info) { // Make sure this is still the active thread for the main Tlen connection + TlenLog(info->proto, "Reconnecting to the network..."); if (numRetry < MAX_CONNECT_RETRIES) numRetry++; oldStatus = info->proto->m_iStatus; @@ -259,7 +259,7 @@ void __cdecl JabberServerThread(ThreadData *info) continue; } else { - JabberLog(info->proto, "Thread ended, connection failed"); + TlenLog(info->proto, "Thread ended, connection failed"); mir_free(buffer); mir_free(info); return; @@ -267,7 +267,7 @@ void __cdecl JabberServerThread(ThreadData *info) } info->proto->threadData = NULL; } - JabberLog(info->proto, "Thread ended, connection failed"); + TlenLog(info->proto, "Thread ended, connection failed"); mir_free(buffer); mir_free(info); return; @@ -277,32 +277,32 @@ void __cdecl JabberServerThread(ThreadData *info) if (info->proto->m_iDesiredStatus != ID_STATUS_OFFLINE) { info->proto->isConnected = TRUE; - JabberForkThread(JabberKeepAliveThread, 0, info->proto); + TlenForkThread(TlenKeepAliveThread, 0, info->proto); - JabberXmlInitState(&xmlState); - JabberXmlSetCallback(&xmlState, 1, ELEM_OPEN, (void (__cdecl *)(XmlNode *,void *))JabberProcessStreamOpening, info); - JabberXmlSetCallback(&xmlState, 1, ELEM_CLOSE, (void (__cdecl *)(XmlNode *,void *))JabberProcessStreamClosing, info); - JabberXmlSetCallback(&xmlState, 2, ELEM_CLOSE, (void (__cdecl *)(XmlNode *,void *))JabberProcessProtocol, info); + TlenXmlInitState(&xmlState); + TlenXmlSetCallback(&xmlState, 1, ELEM_OPEN, (void (__cdecl *)(XmlNode *,void *))TlenProcessStreamOpening, info); + TlenXmlSetCallback(&xmlState, 1, ELEM_CLOSE, (void (__cdecl *)(XmlNode *,void *))TlenProcessStreamClosing, info); + TlenXmlSetCallback(&xmlState, 2, ELEM_CLOSE, (void (__cdecl *)(XmlNode *,void *))TlenProcessProtocol, info); info->useAES = FALSE; if (info->useEncryption) { - JabberSend(info->proto, ""); + TlenSend(info->proto, ""); } else { - JabberSend(info->proto, ""); + TlenSend(info->proto, ""); } - JabberLog(info->proto, "Entering main recv loop"); + TlenLog(info->proto, "Entering main recv loop"); datalen = 0; for (;;) { int recvResult, bytesParsed; if (info->useAES) { - recvResult = JabberWsRecvAES(info->proto, buffer+datalen, jabberNetworkBufferSize-datalen, &info->aes_in_context, info->aes_in_iv); + recvResult = TlenWsRecvAES(info->proto, buffer+datalen, tlenNetworkBufferSize-datalen, &info->aes_in_context, info->aes_in_iv); } else { - recvResult = JabberWsRecv(info->proto, info->s, buffer+datalen, jabberNetworkBufferSize-datalen); + recvResult = TlenWsRecv(info->proto, info->s, buffer+datalen, tlenNetworkBufferSize-datalen); } if (recvResult <= 0) @@ -310,29 +310,29 @@ void __cdecl JabberServerThread(ThreadData *info) datalen += recvResult; buffer[datalen] = '\0'; - JabberLog(info->proto, "RECV:%s", buffer); + TlenLog(info->proto, "RECV:%s", buffer); - bytesParsed = JabberXmlParse(&xmlState, buffer, datalen); - JabberLog(info->proto, "bytesParsed = %d", bytesParsed); + bytesParsed = TlenXmlParse(&xmlState, buffer, datalen); + TlenLog(info->proto, "bytesParsed = %d", bytesParsed); if (bytesParsed > 0) { if (bytesParsed < datalen) memmove(buffer, buffer+bytesParsed, datalen-bytesParsed); datalen -= bytesParsed; } - else if (datalen == jabberNetworkBufferSize) { - jabberNetworkBufferSize += 2048; - JabberLog(info->proto, "Increasing network buffer size to %d", jabberNetworkBufferSize); - if ((buffer=(char *) mir_realloc(buffer, jabberNetworkBufferSize+1)) == NULL) { - JabberLog(info->proto, "Cannot reallocate more network buffer, go offline now"); + else if (datalen == tlenNetworkBufferSize) { + tlenNetworkBufferSize += 2048; + TlenLog(info->proto, "Increasing network buffer size to %d", tlenNetworkBufferSize); + if ((buffer=(char *) mir_realloc(buffer, tlenNetworkBufferSize+1)) == NULL) { + TlenLog(info->proto, "Cannot reallocate more network buffer, go offline now"); break; } } else { - JabberLog(info->proto, "Unknown state: bytesParsed=%d, datalen=%d, jabberNetworkBufferSize=%d", bytesParsed, datalen, jabberNetworkBufferSize); + TlenLog(info->proto, "Unknown state: bytesParsed=%d, datalen=%d, tlenNetworkBufferSize=%d", bytesParsed, datalen, tlenNetworkBufferSize); } } - JabberXmlDestroyState(&xmlState); + TlenXmlDestroyState(&xmlState); info->proto->isOnline = FALSE; info->proto->isConnected = FALSE; @@ -354,7 +354,7 @@ void __cdecl JabberServerThread(ThreadData *info) if (db_get_w(hContact, szProto, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) db_set_w(hContact, szProto, "Status", ID_STATUS_OFFLINE); - JabberListWipeSpecial(info->proto); + TlenListWipeSpecial(info->proto); } else { oldStatus = info->proto->m_iStatus; @@ -367,15 +367,15 @@ void __cdecl JabberServerThread(ThreadData *info) if (info->proto->tlenOptions.reconnect == FALSE) break; - if (info->proto->threadData != info) // Make sure this is still the main Jabber connection thread + if (info->proto->threadData != info) // Make sure this is still the main Tlen connection thread break; reconnectTime = rand() % 10; - JabberLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); + TlenLog(info->proto, "Sleeping %d seconds before automatic reconnecting...", reconnectTime); SleepEx(reconnectTime * 1000, TRUE); reconnectMaxTime = 20; - if (info->proto->threadData != info) // Make sure this is still the main Jabber connection thread + if (info->proto->threadData != info) // Make sure this is still the main Tlen connection thread break; - JabberLog(info->proto, "Reconnecting to the network..."); + TlenLog(info->proto, "Reconnecting to the network..."); info->proto->m_iDesiredStatus = oldStatus; // Reconnect to my last status oldStatus = info->proto->m_iStatus; info->proto->m_iStatus = ID_STATUS_CONNECTING; @@ -383,7 +383,7 @@ void __cdecl JabberServerThread(ThreadData *info) ProtoBroadcastAck(info->proto->m_szModuleName, NULL, ACKTYPE_STATUS, ACKRESULT_SUCCESS, (HANDLE) oldStatus, info->proto->m_iStatus); } - JabberLog(info->proto, "Thread ended: server='%s'", info->server); + TlenLog(info->proto, "Thread ended: server='%s'", info->server); if (info->proto->threadData == info) { info->proto->threadData = NULL; @@ -391,7 +391,7 @@ void __cdecl JabberServerThread(ThreadData *info) mir_free(buffer); if (info->streamId) mir_free(info->streamId); - JabberLog(info->proto, "Exiting ServerThread"); + TlenLog(info->proto, "Exiting ServerThread"); mir_free(info); } @@ -403,28 +403,28 @@ static void TlenSendAuth(TlenProtocol *proto) { str = TlenPasswordHash(proto->threadData->password); mir_snprintf(text, SIZEOF(text), "%s%s", proto->threadData->streamId, str); mir_free(str); - str = JabberSha1(text); - if ((p=JabberTextEncode(proto->threadData->username)) != NULL) { - iqId = JabberSerialNext(proto->threadData->proto); - JabberIqAdd(proto, iqId, IQ_PROC_NONE, JabberIqResultAuth); - JabberSend(proto, "%s%sttlen.pl", iqId, p /*info->username*/, str); + str = TlenSha1(text); + if ((p=TlenTextEncode(proto->threadData->username)) != NULL) { + iqId = TlenSerialNext(proto->threadData->proto); + TlenIqAdd(proto, iqId, IQ_PROC_NONE, TlenIqResultAuth); + TlenSend(proto, "%s%sttlen.pl", iqId, p /*info->username*/, str); mir_free(p); } mir_free(str); } -static void JabberProcessStreamOpening(XmlNode *node, ThreadData *info) +static void TlenProcessStreamOpening(XmlNode *node, ThreadData *info) { char *sid, *s; if (node->name == NULL || strcmp(node->name, "s")) return; - if ((sid=JabberXmlGetAttrValue(node, "i")) != NULL) { + if ((sid=TlenXmlGetAttrValue(node, "i")) != NULL) { if (info->streamId) mir_free(info->streamId); info->streamId = mir_strdup(sid); } - if ((s=JabberXmlGetAttrValue(node, "s")) != NULL && !strcmp(s, "1")) { + if ((s=TlenXmlGetAttrValue(node, "s")) != NULL && !strcmp(s, "1")) { int i; char *k1, *k2, *k3; unsigned char aes_key[32]; @@ -432,9 +432,9 @@ static void JabberProcessStreamOpening(XmlNode *node, ThreadData *info) mpi k1_mpi, k2_mpi, aes_mpi; size_t slen; - k1=JabberXmlGetAttrValue(node, "k1"); - k2=JabberXmlGetAttrValue(node, "k2"); - k3=JabberXmlGetAttrValue(node, "k3"); + k1=TlenXmlGetAttrValue(node, "k1"); + k2=TlenXmlGetAttrValue(node, "k2"); + k3=TlenXmlGetAttrValue(node, "k3"); memset(&info->aes_in_context, 0, sizeof (aes_context)); memset(&info->aes_out_context, 0, sizeof (aes_context)); @@ -462,27 +462,27 @@ static void JabberProcessStreamOpening(XmlNode *node, ThreadData *info) mpi_exp_mod( &aes_mpi, &aes_mpi, &k1_mpi, &k2_mpi, NULL ); slen = 140; mpi_write_string(&aes_mpi, 16, aes_key_str, &slen); - JabberSend(info->proto, "", aes_key_str, aes_iv_str); + TlenSend(info->proto, "", aes_key_str, aes_iv_str); } else { TlenSendAuth(info->proto); } } -static void JabberProcessStreamClosing(XmlNode *node, ThreadData *info) +static void TlenProcessStreamClosing(XmlNode *node, ThreadData *info) { Netlib_CloseHandle(info->proto); if (node->name && !strcmp(node->name, "stream:error") && node->text) - MessageBoxA(NULL, Translate(node->text), Translate("Jabber Connection Error"), MB_OK|MB_ICONERROR|MB_SETFOREGROUND); + MessageBoxA(NULL, Translate(node->text), Translate("Tlen Connection Error"), MB_OK|MB_ICONERROR|MB_SETFOREGROUND); } -static void JabberProcessProtocol(XmlNode *node, ThreadData *info) +static void TlenProcessProtocol(XmlNode *node, ThreadData *info) { if (!strcmp(node->name, "message")) - JabberProcessMessage(node, info); + TlenProcessMessage(node, info); else if (!strcmp(node->name, "presence")) TlenProcessPresence(node, info->proto); else if (!strcmp(node->name, "iq")) - JabberProcessIq(node, info); + TlenProcessIq(node, info); else if (!strcmp(node->name, "f")) TlenProcessF(node, info); else if (!strcmp(node->name, "w")) @@ -500,16 +500,16 @@ static void JabberProcessProtocol(XmlNode *node, ThreadData *info) else if (!strcmp(node->name, "cipher")) TlenProcessCipher(node, info); else - JabberLog(info->proto, "Invalid top-level tag (only

and allowed)"); + TlenLog(info->proto, "Invalid top-level tag (only

and allowed)"); } static void TlenProcessCipher(XmlNode *node, ThreadData *info) { char *type; - type=JabberXmlGetAttrValue(node, "type"); + type=TlenXmlGetAttrValue(node, "type"); info->useAES = TRUE; - JabberSend(info->proto, ""); + TlenSend(info->proto, ""); TlenSendAuth(info->proto); } @@ -519,47 +519,47 @@ static void TlenProcessIqGetVersion(TlenProtocol *proto, XmlNode* node) char mversion[256]; char* from, *version, *mver; char* os = NULL; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; if (proto->m_iStatus == ID_STATUS_INVISIBLE) return; if (!proto->tlenOptions.enableVersion) return; - if (( from=JabberXmlGetAttrValue( node, "from" )) == NULL ) return; - if (( item=JabberListGetItemPtr( proto, LIST_ROSTER, from )) ==NULL) return; - version = JabberTextEncode( TLEN_VERSION_STRING ); + if (( from=TlenXmlGetAttrValue( node, "from" )) == NULL ) return; + if (( item=TlenListGetItemPtr( proto, LIST_ROSTER, from )) ==NULL) return; + version = TlenTextEncode( TLEN_VERSION_STRING ); osvi.dwOSVersionInfoSize = sizeof( OSVERSIONINFO ); if ( GetVersionEx( &osvi )) { switch ( osvi.dwPlatformId ) { case VER_PLATFORM_WIN32_NT: if ( osvi.dwMajorVersion == 5 ) { - if ( osvi.dwMinorVersion == 2 ) os = JabberTextEncode( Translate( "Windows Server 2003" )); - else if ( osvi.dwMinorVersion == 1 ) os = JabberTextEncode( Translate( "Windows XP" )); - else if ( osvi.dwMinorVersion == 0 ) os = JabberTextEncode( Translate( "Windows 2000" )); + if ( osvi.dwMinorVersion == 2 ) os = TlenTextEncode( Translate( "Windows Server 2003" )); + else if ( osvi.dwMinorVersion == 1 ) os = TlenTextEncode( Translate( "Windows XP" )); + else if ( osvi.dwMinorVersion == 0 ) os = TlenTextEncode( Translate( "Windows 2000" )); } else if ( osvi.dwMajorVersion <= 4 ) { - os = JabberTextEncode( Translate( "Windows NT" )); + os = TlenTextEncode( Translate( "Windows NT" )); } break; case VER_PLATFORM_WIN32_WINDOWS: if ( osvi.dwMajorVersion == 4 ) { - if ( osvi.dwMinorVersion == 0 ) os = JabberTextEncode( Translate( "Windows 95" )); - if ( osvi.dwMinorVersion == 10 ) os = JabberTextEncode( Translate( "Windows 98" )); - if ( osvi.dwMinorVersion == 90 ) os = JabberTextEncode( Translate( "Windows ME" )); + if ( osvi.dwMinorVersion == 0 ) os = TlenTextEncode( Translate( "Windows 95" )); + if ( osvi.dwMinorVersion == 10 ) os = TlenTextEncode( Translate( "Windows 98" )); + if ( osvi.dwMinorVersion == 90 ) os = TlenTextEncode( Translate( "Windows ME" )); } break; } } - if ( os == NULL ) os = JabberTextEncode( Translate( "Windows" )); + if ( os == NULL ) os = TlenTextEncode( Translate( "Windows" )); strcpy(mversion, "Miranda NG "); CallService(MS_SYSTEM_GETVERSIONTEXT, sizeof( mversion ) - 11, ( LPARAM )mversion + 11 ); strcat(mversion, " (Tlen v."); strcat(mversion, TLEN_VERSION_STRING); strcat(mversion, ")"); - mver = JabberTextEncode( mversion ); - JabberSend( proto, "%s%s%s", from, mver?mver:"", version?version:"", os?os:"" ); + mver = TlenTextEncode( mversion ); + TlenSend( proto, "%s%s%s", from, mver?mver:"", version?version:"", os?os:"" ); if (!item->versionRequested) { item->versionRequested = TRUE; - JabberSend(proto, "", from); + TlenSend(proto, "", from); } if ( mver ) mir_free( mver ); @@ -571,8 +571,8 @@ static void TlenProcessIqGetVersion(TlenProtocol *proto, XmlNode* node) static void TlenProcessAvatar(XmlNode* node, ThreadData *info) { XmlNode *tokenNode, *aNode; - tokenNode = JabberXmlGetChild(node, "token"); - aNode = JabberXmlGetChild(node, "a"); + tokenNode = TlenXmlGetChild(node, "token"); + aNode = TlenXmlGetChild(node, "a"); if (tokenNode != NULL) { char *token = tokenNode->text; strcpy(info->avatarToken, token); @@ -583,7 +583,7 @@ static void TlenProcessAvatar(XmlNode* node, ThreadData *info) } } -static void JabberProcessMessage(XmlNode *node, ThreadData *info) +static void TlenProcessMessage(XmlNode *node, ThreadData *info) { HANDLE hContact; PROTORECVEVENT recv; @@ -592,69 +592,69 @@ static void JabberProcessMessage(XmlNode *node, ThreadData *info) DWORD msgTime; BOOL delivered, composing; int i; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; BOOL isChatRoomJid; if (!node->name || strcmp(node->name, "message")) return; - if ((type=JabberXmlGetAttrValue(node, "type")) != NULL && !strcmp(type, "error")) { + if ((type=TlenXmlGetAttrValue(node, "type")) != NULL && !strcmp(type, "error")) { } else { - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { - char *fromJid = JabberLoginFromJID(from); + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { + char *fromJid = TlenLoginFromJID(from); if (info->proto->tlenOptions.ignoreAdvertisements && strstr(from, "b73@tlen.pl") == from) { return; } // If message is from a stranger (not in roster), item is NULL - item = JabberListGetItemPtr(info->proto, LIST_ROSTER, fromJid); - isChatRoomJid = JabberListExist(info->proto, LIST_CHATROOM, from); + item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fromJid); + isChatRoomJid = TlenListExist(info->proto, LIST_CHATROOM, from); if (isChatRoomJid && type != NULL && !strcmp(type, "groupchat")) { - //JabberGroupchatProcessMessage(node, userdata); + //TlenGroupchatProcessMessage(node, userdata); } else if (type != NULL && !strcmp(type, "pic")) { TlenProcessPic(node, info->proto); } else if (type != NULL && !strcmp(type, "iq")) { XmlNode *iqNode; - // Jabber-compatible iq - if ((iqNode=JabberXmlGetChild(node, "iq")) != NULL) { - JabberXmlAddAttr(iqNode, "from", from); - JabberProcessIq(iqNode, info); + // Tlen-compatible iq + if ((iqNode=TlenXmlGetChild(node, "iq")) != NULL) { + TlenXmlAddAttr(iqNode, "from", from); + TlenProcessIq(iqNode, info); } } else { - if ((bodyNode=JabberXmlGetChild(node, "body")) != NULL) { + if ((bodyNode=TlenXmlGetChild(node, "body")) != NULL) { if (bodyNode->text != NULL) { - if ((subjectNode=JabberXmlGetChild(node, "subject")) != NULL && subjectNode->text != NULL && subjectNode->text[0] != '\0') { + if ((subjectNode=TlenXmlGetChild(node, "subject")) != NULL && subjectNode->text != NULL && subjectNode->text[0] != '\0') { size_t size = strlen(subjectNode->text)+strlen(bodyNode->text)+5; p = (char *)mir_alloc(size); mir_snprintf(p, size, "%s\r\n%s", subjectNode->text, bodyNode->text); - localMessage = JabberTextDecode(p); + localMessage = TlenTextDecode(p); mir_free(p); } else { - localMessage = JabberTextDecode(bodyNode->text); + localMessage = TlenTextDecode(bodyNode->text); } msgTime = 0; delivered = composing = FALSE; i = 1; - while ((xNode=JabberXmlGetNthChild(node, "x", i)) != NULL) { - if ((p=JabberXmlGetAttrValue(xNode, "xmlns")) != NULL) { - if (!strcmp(p, "jabber:x:delay") && msgTime==0) { - if ((p=JabberXmlGetAttrValue(xNode, "stamp")) != NULL) { - msgTime = JabberIsoToUnixTime(p); + while ((xNode=TlenXmlGetNthChild(node, "x", i)) != NULL) { + if ((p=TlenXmlGetAttrValue(xNode, "xmlns")) != NULL) { + if (!strcmp(p, "tlen:x:delay") && msgTime==0) { + if ((p=TlenXmlGetAttrValue(xNode, "stamp")) != NULL) { + msgTime = TlenIsoToUnixTime(p); } } - else if (!strcmp(p, "jabber:x:event")) { + else if (!strcmp(p, "tlen:x:event")) { // Check whether any event is requested - if (!delivered && (n=JabberXmlGetChild(xNode, "delivered")) != NULL) { + if (!delivered && (n=TlenXmlGetChild(xNode, "delivered")) != NULL) { delivered = TRUE; - idStr = JabberXmlGetAttrValue(node, "id"); - JabberSend(info->proto, "%s", from, (idStr != NULL)?idStr:""); + idStr = TlenXmlGetAttrValue(node, "id"); + TlenSend(info->proto, "%s", from, (idStr != NULL)?idStr:""); } - if (item != NULL && JabberXmlGetChild(xNode, "composing") != NULL) { + if (item != NULL && TlenXmlGetChild(xNode, "composing") != NULL) { composing = TRUE; if (item->messageEventIdStr) mir_free(item->messageEventIdStr); - idStr = JabberXmlGetAttrValue(node, "id"); + idStr = TlenXmlGetAttrValue(node, "id"); item->messageEventIdStr = (idStr == NULL)?NULL:mir_strdup(idStr); } } @@ -666,24 +666,24 @@ static void JabberProcessMessage(XmlNode *node, ThreadData *info) item->wantComposingEvent = composing; if (item->isTyping) { item->isTyping = FALSE; - if ((hContact=JabberHContactFromJID(info->proto, fromJid)) != NULL) + if ((hContact=TlenHContactFromJID(info->proto, fromJid)) != NULL) CallService(MS_PROTO_CONTACTISTYPING, (WPARAM) hContact, PROTOTYPE_CONTACTTYPING_OFF); } } - if ((hContact=JabberHContactFromJID(info->proto, fromJid)) == NULL) { + if ((hContact=TlenHContactFromJID(info->proto, fromJid)) == NULL) { // Create a temporary contact if (isChatRoomJid) { if ((p=strchr(from, '/')) != NULL && p[1]!='\0') p++; else p = from; - nick = JabberTextEncode(p); - hContact = JabberDBCreateContact(info->proto, from, nick, TRUE); + nick = TlenTextEncode(p); + hContact = TlenDBCreateContact(info->proto, from, nick, TRUE); } else { - nick = JabberLocalNickFromJID(from); - hContact = JabberDBCreateContact(info->proto, from, nick, TRUE); + nick = TlenLocalNickFromJID(from); + hContact = TlenDBCreateContact(info->proto, from, nick, TRUE); } mir_free(nick); } @@ -717,7 +717,7 @@ static void JabberProcessMessage(XmlNode *node, ThreadData *info) } } -static void JabberProcessIq(XmlNode *node, ThreadData *info) +static void TlenProcessIq(XmlNode *node, ThreadData *info) { HANDLE hContact; XmlNode *queryNode = NULL; @@ -726,29 +726,29 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) char *idStr, *str; int id; int i; - JABBER_IQ_PFUNC pfunc; + TLEN_IQ_PFUNC pfunc; if (!node->name || strcmp(node->name, "iq")) return; - type=JabberXmlGetAttrValue(node, "type"); -// if ((type=JabberXmlGetAttrValue(node, "type")) == NULL) return; + type=TlenXmlGetAttrValue(node, "type"); +// if ((type=TlenXmlGetAttrValue(node, "type")) == NULL) return; id = -1; - if ((idStr=JabberXmlGetAttrValue(node, "id")) != NULL) { - if (!strncmp(idStr, JABBER_IQID, strlen(JABBER_IQID))) - id = atoi(idStr+strlen(JABBER_IQID)); + if ((idStr=TlenXmlGetAttrValue(node, "id")) != NULL) { + if (!strncmp(idStr, TLEN_IQID, strlen(TLEN_IQID))) + id = atoi(idStr+strlen(TLEN_IQID)); } - queryNode = JabberXmlGetChild(node, "query"); + queryNode = TlenXmlGetChild(node, "query"); if (queryNode != NULL) { - xmlns = JabberXmlGetAttrValue(queryNode, "xmlns"); + xmlns = TlenXmlGetAttrValue(queryNode, "xmlns"); } ///////////////////////////////////////////////////////////////////////// // MATCH BY ID ///////////////////////////////////////////////////////////////////////// - if ((pfunc=JabberIqFetchFunc(info->proto, id)) != NULL) { - JabberLog(info->proto, "Handling iq request for id=%d", id); + if ((pfunc=TlenIqFetchFunc(info->proto, id)) != NULL) { + TlenLog(info->proto, "Handling iq request for id=%d", id); pfunc(info->proto, node); ///////////////////////////////////////////////////////////////////////// // MORE GENERAL ROUTINES, WHEN ID DOES NOT MATCH @@ -764,38 +764,38 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) // RECVED: roster push // ACTION: similar to iqIdGetRoster above - if (!strcmp(xmlns, "jabber:iq:roster")) { + if (!strcmp(xmlns, "tlen:iq:roster")) { XmlNode *itemNode, *groupNode; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char *name; - JabberLog(info->proto, " Got roster push, query has %d children", queryNode->numChild); + TlenLog(info->proto, " Got roster push, query has %d children", queryNode->numChild); for (i=0; inumChild; i++) { itemNode = queryNode->child[i]; if (!strcmp(itemNode->name, "item")) { - if ((jid=JabberXmlGetAttrValue(itemNode, "jid")) != NULL) { - if ((str=JabberXmlGetAttrValue(itemNode, "subscription")) != NULL) { + if ((jid=TlenXmlGetAttrValue(itemNode, "jid")) != NULL) { + if ((str=TlenXmlGetAttrValue(itemNode, "subscription")) != NULL) { // we will not add new account when subscription=remove if (!strcmp(str, "to") || !strcmp(str, "both") || !strcmp(str, "from") || !strcmp(str, "none")) { - if ((name=JabberXmlGetAttrValue(itemNode, "name")) != NULL) { - nick = JabberTextDecode(name); + if ((name=TlenXmlGetAttrValue(itemNode, "name")) != NULL) { + nick = TlenTextDecode(name); } else { - nick = JabberLocalNickFromJID(jid); + nick = TlenLocalNickFromJID(jid); } if (nick != NULL) { - if ((item=JabberListAdd(info->proto, LIST_ROSTER, jid)) != NULL) { + if ((item=TlenListAdd(info->proto, LIST_ROSTER, jid)) != NULL) { if (item->nick) mir_free(item->nick); item->nick = nick; - if ((hContact=JabberHContactFromJID(info->proto, jid)) == NULL) { + if ((hContact=TlenHContactFromJID(info->proto, jid)) == NULL) { // Received roster has a new JID. // Add the jid (with empty resource) to Miranda contact list. - hContact = JabberDBCreateContact(info->proto, jid, nick, FALSE); + hContact = TlenDBCreateContact(info->proto, jid, nick, FALSE); } db_set_s(hContact, "CList", "MyHandle", nick); if (item->group) mir_free(item->group); - if ((groupNode=JabberXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { + if ((groupNode=TlenXmlGetChild(itemNode, "group")) != NULL && groupNode->text != NULL) { item->group = TlenGroupDecode(groupNode->text); - JabberContactListCreateGroup(item->group); + TlenContactListCreateGroup(item->group); db_set_s(hContact, "CList", "Group", item->group); } else { @@ -812,20 +812,20 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) } } } - if ((item=JabberListGetItemPtr(info->proto, LIST_ROSTER, jid)) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_ROSTER, jid)) != NULL) { if (!strcmp(str, "both")) item->subscription = SUB_BOTH; else if (!strcmp(str, "to")) item->subscription = SUB_TO; else if (!strcmp(str, "from")) item->subscription = SUB_FROM; else item->subscription = SUB_NONE; - JabberLog(info->proto, "Roster push for jid=%s, set subscription to %s", jid, str); + TlenLog(info->proto, "Roster push for jid=%s, set subscription to %s", jid, str); // subscription = remove is to remove from roster list // but we will just set the contact to offline and not actually // remove, so that history will be retained. if (!strcmp(str, "remove")) { - if ((hContact=JabberHContactFromJID(info->proto, jid)) != NULL) { + if ((hContact=TlenHContactFromJID(info->proto, jid)) != NULL) { if (db_get_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE) != ID_STATUS_OFFLINE) db_set_w(hContact, info->proto->m_szModuleName, "Status", ID_STATUS_OFFLINE); - JabberListRemove(info->proto, LIST_ROSTER, jid); + TlenListRemove(info->proto, LIST_ROSTER, jid); } } } @@ -840,21 +840,21 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) else if ( !strcmp( type, "get" ) && queryNode != NULL && xmlns != NULL ) { // RECVED: software version query // ACTION: return my software version - if ( !strcmp( xmlns, "jabber:iq:version" )) TlenProcessIqGetVersion(info->proto, node); + if ( !strcmp( xmlns, "tlen:iq:version" )) TlenProcessIqGetVersion(info->proto, node); } // RECVED: proto, node); - } else if ( !strcmp( xmlns, "jabber:iq:version" )) { + if ( !strcmp(xmlns, "tlen:iq:roster" )) { + TlenIqResultRoster(info->proto, node); + } else if ( !strcmp( xmlns, "tlen:iq:version" )) { TlenIqResultVersion(info->proto, node); - } else if ( !strcmp( xmlns, "jabber:iq:info" )) { + } else if ( !strcmp( xmlns, "tlen:iq:info" )) { TlenIqResultInfo(info->proto, node); } } else { char *from; - if (( from=JabberXmlGetAttrValue( node, "from" )) != NULL ) { + if (( from=TlenXmlGetAttrValue( node, "from" )) != NULL ) { if ( !strcmp(from, "tcfg" )) { TlenIqResultTcfg(info->proto, node); } @@ -863,10 +863,10 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) } // RECVED: ... else if (!strcmp(type, "error")) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; // Check for multi-user chat errors char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strstr(from, "@c") != NULL || !strcmp(from, "c")) { TlenMUCRecvError(info->proto, from, node); return; @@ -875,8 +875,8 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) // Check for file transfer deny by comparing idStr with ft->iqId i = 0; - while ((i=JabberListFindNext(info->proto, LIST_FILE, i)) >= 0) { - item = JabberListGetItemPtrFromIndex(info->proto,i); + while ((i=TlenListFindNext(info->proto, LIST_FILE, i)) >= 0) { + item = TlenListGetItemPtrFromIndex(info->proto,i); if (item->ft->state==FT_CONNECTING && !strcmp(idStr, item->ft->iqId)) { item->ft->state = FT_DENIED; if (item->ft->hFileEvent != NULL) @@ -888,7 +888,7 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) // RECVED: ... else if (!strcmp(type, "1")) { // Chat groups list result char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultChatGroups(info->proto, node); } @@ -896,49 +896,49 @@ static void JabberProcessIq(XmlNode *node, ThreadData *info) } else if (!strcmp(type, "2")) { // Chat rooms list result char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultChatRooms(info->proto, node); } } } else if (!strcmp(type, "3")) { // room search result - result to iq type 3 query char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultRoomSearch(info->proto, node); } } } else if (!strcmp(type, "4")) { // chat room users list char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strstr(from, "@c") != NULL) { TlenIqResultChatRoomUsers(info->proto, node); } } } else if (!strcmp(type, "5")) { // room name & group & flags info - sent on joining the room char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strstr(from, "@c") != NULL) { TlenIqResultRoomInfo(info->proto, node); } } } else if (!strcmp(type, "6")) { // new nick registered char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultUserNicks(info->proto, node); } } } else if (!strcmp(type, "7")) { // user nicknames list char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultUserNicks(info->proto, node); } } } else if (!strcmp(type, "8")) { // user chat rooms list char *from; - if ((from=JabberXmlGetAttrValue(node, "from")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "from")) != NULL) { if (strcmp(from, "c") == 0) { TlenIqResultUserRooms(info->proto, node); } @@ -960,29 +960,29 @@ static void TlenProcessW(XmlNode *node, ThreadData *info) if (!node->name || strcmp(node->name, "w")) return; if ((body=node->text) == NULL) return; - if ((f=JabberXmlGetAttrValue(node, "f")) != NULL) { + if ((f=TlenXmlGetAttrValue(node, "f")) != NULL) { char webContactName[128]; mir_snprintf(webContactName, SIZEOF(webContactName), Translate("%s Web Messages"), info->proto->m_szModuleName); - if ((hContact=JabberHContactFromJID(info->proto, webContactName)) == NULL) { - hContact = JabberDBCreateContact(info->proto, webContactName, webContactName, TRUE); + if ((hContact=TlenHContactFromJID(info->proto, webContactName)) == NULL) { + hContact = TlenDBCreateContact(info->proto, webContactName, webContactName, TRUE); } - s = JabberXmlGetAttrValue(node, "s"); - e = JabberXmlGetAttrValue(node, "e"); + s = TlenXmlGetAttrValue(node, "s"); + e = TlenXmlGetAttrValue(node, "e"); str = NULL; strSize = 0; - JabberStringAppend(&str, &strSize, "%s\r\n%s: ", Translate("Web message"), Translate("From")); + TlenStringAppend(&str, &strSize, "%s\r\n%s: ", Translate("Web message"), Translate("From")); if (f != NULL) - JabberStringAppend(&str, &strSize, "%s", f); - JabberStringAppend(&str, &strSize, "\r\n%s: ", Translate("E-mail")); + TlenStringAppend(&str, &strSize, "%s", f); + TlenStringAppend(&str, &strSize, "\r\n%s: ", Translate("E-mail")); if (e != NULL) - JabberStringAppend(&str, &strSize, "%s", e); - JabberStringAppend(&str, &strSize, "\r\n\r\n%s", body); + TlenStringAppend(&str, &strSize, "%s", e); + TlenStringAppend(&str, &strSize, "\r\n\r\n%s", body); - localMessage = JabberTextDecode(str); + localMessage = TlenTextDecode(str); recv.flags = 0; recv.timestamp = (DWORD) time(NULL); @@ -1010,11 +1010,11 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) if (!node->name || strcmp(node->name, "m")) return; - if ((f=JabberXmlGetAttrValue(node, "f")) != NULL) { - char *fLogin = JabberLoginFromJID(f); - if ((hContact=JabberHContactFromJID(info->proto, fLogin)) != NULL) { - if ((tp=JabberXmlGetAttrValue(node, "tp")) != NULL) { - JABBER_LIST_ITEM *item = JabberListGetItemPtr(info->proto, LIST_ROSTER, fLogin); + if ((f=TlenXmlGetAttrValue(node, "f")) != NULL) { + char *fLogin = TlenLoginFromJID(f); + if ((hContact=TlenHContactFromJID(info->proto, fLogin)) != NULL) { + if ((tp=TlenXmlGetAttrValue(node, "tp")) != NULL) { + TLEN_LIST_ITEM *item = TlenListGetItemPtr(info->proto, LIST_ROSTER, fLogin); if (!strcmp(tp, "t")) { //contact is writing if (item != NULL ) { item->isTyping = TRUE; @@ -1051,7 +1051,7 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) if ((p=strchr(f, '@')) != NULL) { if ((p=strchr(p, '/')) != NULL && p[1]!='\0') { // message from user time_t timestamp; - s = JabberXmlGetAttrValue(node, "s"); + s = TlenXmlGetAttrValue(node, "s"); if (s != NULL) { timestamp = TlenTimeToUTC(atol(s)); if (timestamp > time(NULL)) { @@ -1060,17 +1060,17 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) } else { timestamp = time(NULL); } - tp=JabberXmlGetAttrValue(node, "tp"); - bNode = JabberXmlGetChild(node, "b"); - f = JabberTextDecode(f); + tp=TlenXmlGetAttrValue(node, "tp"); + bNode = TlenXmlGetChild(node, "b"); + f = TlenTextDecode(f); if (bNode != NULL && bNode->text != NULL) { if (tp != NULL && !strcmp(tp, "p")) { /* MUC private message */ - str = JabberResourceFromJID(f); - hContact = JabberDBCreateContact(info->proto, f, str, TRUE); + str = TlenResourceFromJID(f); + hContact = TlenDBCreateContact(info->proto, f, str, TRUE); db_set_b(hContact, info->proto->m_szModuleName, "bChat", TRUE); mir_free(str); - localMessage = JabberTextDecode(bNode->text); + localMessage = TlenTextDecode(bNode->text); recv.flags = 0; recv.timestamp = (DWORD) timestamp; recv.szMessage = localMessage; @@ -1084,14 +1084,14 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) } mir_free(f); } else { // message from chat room (system) - subjectNode = JabberXmlGetChild(node, "subject"); + subjectNode = TlenXmlGetChild(node, "subject"); if (subjectNode != NULL) { - f = JabberTextDecode(f); + f = TlenTextDecode(f); localMessage = ""; if (subjectNode->text != NULL) { localMessage = subjectNode->text; } - localMessage = JabberTextDecode(localMessage); + localMessage = TlenTextDecode(localMessage); TlenMUCRecvTopic(info->proto, f, localMessage); mir_free(localMessage); mir_free(f); @@ -1099,18 +1099,18 @@ static void TlenProcessM(XmlNode *node, ThreadData *info) } } i=1; - while ((xNode=JabberXmlGetNthChild(node, "x", i)) != NULL) { - invNode=JabberXmlGetChild(xNode, "inv"); + while ((xNode=TlenXmlGetNthChild(node, "x", i)) != NULL) { + invNode=TlenXmlGetChild(xNode, "inv"); if (invNode != NULL) { - r = JabberTextDecode(f); - f = JabberXmlGetAttrValue(invNode, "f"); - f = JabberTextDecode(f); - n = JabberXmlGetAttrValue(invNode, "n"); + r = TlenTextDecode(f); + f = TlenXmlGetAttrValue(invNode, "f"); + f = TlenTextDecode(f); + n = TlenXmlGetAttrValue(invNode, "n"); if (n != NULL && strstr(r, n) != r) { - n = JabberTextDecode(n); + n = TlenTextDecode(n); } else { n = mir_strdup(Translate("Private conference")); - //n = JabberNickFromJID(r); + //n = TlenNickFromJID(r); } TlenMUCRecvInvitation(info->proto, r, n, f, ""); mir_free(n); @@ -1154,22 +1154,22 @@ static void TlenProcessN(XmlNode *node, ThreadData *info) if (!node->name || strcmp(node->name, "n")) return; - s = JabberXmlGetAttrValue(node, "s"); - f = JabberXmlGetAttrValue(node, "f"); + s = TlenXmlGetAttrValue(node, "s"); + f = TlenXmlGetAttrValue(node, "f"); if (s != NULL && f != NULL) { str = NULL; strSize = 0; - JabberStringAppend(&str, &strSize, Translate("%s mail"), info->proto->m_szModuleName); - popupTitle = JabberTextDecode(str); + TlenStringAppend(&str, &strSize, Translate("%s mail"), info->proto->m_szModuleName); + popupTitle = TlenTextDecode(str); mir_free(str); str = NULL; strSize = 0; - JabberStringAppend(&str, &strSize, "%s: %s\n", Translate("From"), f); - JabberStringAppend(&str, &strSize, "%s: %s", Translate("Subject"), s); - popupText = JabberTextDecode(str); + TlenStringAppend(&str, &strSize, "%s: %s\n", Translate("From"), f); + TlenStringAppend(&str, &strSize, "%s: %s", Translate("Subject"), s); + popupText = TlenTextDecode(str); TlenMailPopup(info->proto, popupTitle, popupText); SkinPlaySound("TlenMailNotify"); @@ -1194,34 +1194,34 @@ static void TlenProcessP(XmlNode *node, ThreadData *info) // presence from users in chat room flags = 0; status = ID_STATUS_ONLINE; - f = JabberXmlGetAttrValue(node, "f"); - xNode = JabberXmlGetChild(node, "x"); + f = TlenXmlGetAttrValue(node, "f"); + xNode = TlenXmlGetChild(node, "x"); if (xNode != NULL) { // x subtag present (message from chat room) - change user rights only char *temp, *iStr; - iNode = JabberXmlGetChild(xNode, "i"); + iNode = TlenXmlGetChild(xNode, "i"); if (iNode != NULL) { - iStr = JabberXmlGetAttrValue(iNode, "i"); + iStr = TlenXmlGetAttrValue(iNode, "i"); temp = (char*)mir_alloc(strlen(f)+strlen(iStr)+2); strcpy(temp, f); strcat(temp, "/"); strcat(temp, iStr); - f = JabberTextDecode(temp); + f = TlenTextDecode(temp); mir_free(temp); node = iNode; status = 0; } else { - f = JabberTextDecode(f); + f = TlenTextDecode(f); } } else { - f = JabberTextDecode(f); + f = TlenTextDecode(f); } - a = JabberXmlGetAttrValue(node, "z"); + a = TlenXmlGetAttrValue(node, "z"); if (a != NULL) { if (atoi(a) &1 ) { flags |= USER_FLAGS_REGISTERED; } } - a = JabberXmlGetAttrValue(node, "a"); + a = TlenXmlGetAttrValue(node, "a"); if (a != NULL) { if (atoi(a) == 2) { flags |= USER_FLAGS_ADMIN; @@ -1236,30 +1236,30 @@ static void TlenProcessP(XmlNode *node, ThreadData *info) flags |= USER_FLAGS_GLOBALOWNER; } } - sNode = JabberXmlGetChild(node, "s"); + sNode = TlenXmlGetChild(node, "s"); if (sNode != NULL) { if (!strcmp(sNode->text, "unavailable")) { status = ID_STATUS_OFFLINE; } } - kNode = JabberXmlGetChild(node, "kick"); + kNode = TlenXmlGetChild(node, "kick"); k = NULL; if (kNode != NULL) { - k = JabberXmlGetAttrValue(kNode, "r"); + k = TlenXmlGetAttrValue(kNode, "r"); if (k == NULL) { k = ""; } - k = JabberTextDecode(k); + k = TlenTextDecode(k); } - tp = JabberXmlGetAttrValue(node, "tp"); + tp = TlenXmlGetAttrValue(node, "tp"); if (tp != NULL && !strcmp(tp, "c")) { // new chat room has just been created - id = JabberXmlGetAttrValue(node, "id"); + id = TlenXmlGetAttrValue(node, "id"); if (id != NULL) { - n = JabberXmlGetAttrValue(node, "n"); + n = TlenXmlGetAttrValue(node, "n"); if (n != NULL) { - n = JabberTextDecode(n); + n = TlenTextDecode(n); } else { - n = mir_strdup(Translate("Private conference"));// JabberNickFromJID(f); + n = mir_strdup(Translate("Private conference"));// TlenNickFromJID(f); } mir_snprintf(jid, SIZEOF(jid), "%s/%s", f, info->username); // if (!db_get(NULL, info->proto->m_szModuleName, "LoginName", &dbv)) { @@ -1285,26 +1285,26 @@ static void TlenProcessP(XmlNode *node, ThreadData *info) static void TlenProcessV(XmlNode *node, ThreadData *info) { char jid[128]; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; char *from, *id, *e, *p; // if (!node->name || strcmp(node->name, "v")) return; - if ((from=JabberXmlGetAttrValue(node, "f")) != NULL) { + if ((from=TlenXmlGetAttrValue(node, "f")) != NULL) { if (strchr(from, '@') == NULL) { mir_snprintf(jid, sizeof(jid), "%s@%s", from, info->server); } else { mir_snprintf(jid, sizeof(jid), "%s", from); } - if ((e=JabberXmlGetAttrValue(node, "e")) != NULL) { + if ((e=TlenXmlGetAttrValue(node, "e")) != NULL) { if (!strcmp(e, "1")) { - if ((id=JabberXmlGetAttrValue(node, "i")) != NULL) { + if ((id=TlenXmlGetAttrValue(node, "i")) != NULL) { SkinPlaySound("TlenVoiceNotify"); TlenVoiceAccept(info->proto, id, from); } } else if (!strcmp(e, "3")) { // FILE_RECV : e='3' : invalid transfer error - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { if (item->ft != NULL) { HANDLE hEvent = item->ft->hFileEvent; item->ft->hFileEvent = NULL; @@ -1319,41 +1319,41 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) TlenP2PFreeFileTransfer(item->ft); } } else { - JabberListRemove(info->proto, LIST_VOICE, p); + TlenListRemove(info->proto, LIST_VOICE, p); } } } } else if (!strcmp(e, "4")) { // FILE_SEND : e='4' : File sending request was denied by the remote client - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { if (!strcmp(item->ft->jid, jid)) { TlenVoiceCancelAll(info->proto); - //JabberListRemove(info->proto, LIST_VOICE, p); + //TlenListRemove(info->proto, LIST_VOICE, p); } } } } else if (!strcmp(e, "5")) { // FILE_SEND : e='5' : Voice request was accepted - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { - JabberLog(info->proto, "should start voice 1 ? %s ?? %s", jid, item->ft->jid); + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + TlenLog(info->proto, "should start voice 1 ? %s ?? %s", jid, item->ft->jid); if (!strcmp(item->ft->jid, jid)) { - JabberLog(info->proto, "starting voice 1"); + TlenLog(info->proto, "starting voice 1"); TlenVoiceStart(item->ft, 1); } } } } else if (!strcmp(e, "6")) { // FILE_RECV : e='6' : IP and port information to connect to get file - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { - if ((p=JabberXmlGetAttrValue(node, "a")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) { item->ft->hostName = mir_strdup(p); - if ((p=JabberXmlGetAttrValue(node, "p")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) { item->ft->wPort = atoi(p); TlenVoiceStart(item->ft, 0); - //JabberForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, item->ft); + //TlenForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, item->ft); } } } @@ -1362,12 +1362,12 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) else if (!strcmp(e, "7")) { // FILE_RECV : e='7' : IP and port information to connect to send file // in case the conection to the given server was not successful - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { - if ((p=JabberXmlGetAttrValue(node, "a")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "a")) != NULL) { if (item->ft->hostName != NULL) mir_free(item->ft->hostName); item->ft->hostName = mir_strdup(p); - if ((p=JabberXmlGetAttrValue(node, "p")) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "p")) != NULL) { item->ft->wPort = atoi(p); item->ft->state = FT_SWITCH; SetEvent(item->ft->hFileEvent); @@ -1378,8 +1378,8 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) } else if (!strcmp(e, "8")) { // FILE_RECV : e='8' : transfer error - if ((p=JabberXmlGetAttrValue(node, "i")) != NULL) { - if ((item=JabberListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { + if ((p=TlenXmlGetAttrValue(node, "i")) != NULL) { + if ((item=TlenListGetItemPtr(info->proto, LIST_VOICE, p)) != NULL) { item->ft->state = FT_ERROR; SetEvent(item->ft->hFileEvent); } @@ -1390,7 +1390,7 @@ static void TlenProcessV(XmlNode *node, ThreadData *info) } } -static void __cdecl JabberKeepAliveThread(void *ptr) +static void __cdecl TlenKeepAliveThread(void *ptr) { NETLIBSELECT nls = {0}; @@ -1402,8 +1402,8 @@ static void __cdecl JabberKeepAliveThread(void *ptr) if (CallService(MS_NETLIB_SELECT, 0, (LPARAM) &nls) != 0) break; if (proto->tlenOptions.sendKeepAlive) - JabberSend(proto, " \t "); + TlenSend(proto, " \t "); } - JabberLog(proto, "Exiting KeepAliveThread"); + TlenLog(proto, "Exiting KeepAliveThread"); } diff --git a/protocols/Tlen/src/tlen_userinfo.cpp b/protocols/Tlen/src/tlen_userinfo.cpp index 12e591dc97..4400447fec 100644 --- a/protocols/Tlen/src/tlen_userinfo.cpp +++ b/protocols/Tlen/src/tlen_userinfo.cpp @@ -31,12 +31,12 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "resource.h" #include "tlen_avatar.h" -JABBER_FIELD_MAP tlenFieldGender[] = { +TLEN_FIELD_MAP tlenFieldGender[] = { { 1, _T("Male") }, { 2, _T("Female") }, { 0, NULL } }; -JABBER_FIELD_MAP tlenFieldLookfor[] = { +TLEN_FIELD_MAP tlenFieldLookfor[] = { { 1, _T("Somebody to talk") }, { 2, _T("Friendship") }, { 3, _T("Flirt/romance") }, @@ -44,13 +44,13 @@ JABBER_FIELD_MAP tlenFieldLookfor[] = { { 5, _T("Nothing") }, { 0, NULL } }; -JABBER_FIELD_MAP tlenFieldStatus[] = { +TLEN_FIELD_MAP tlenFieldStatus[] = { { 1, _T("All") }, { 2, _T("Available") }, { 3, _T("Free for chat") }, { 0, NULL } }; -JABBER_FIELD_MAP tlenFieldOccupation[] = { +TLEN_FIELD_MAP tlenFieldOccupation[] = { { 1, _T("Student") }, { 2, _T("College student") }, { 3, _T("Farmer") }, @@ -65,7 +65,7 @@ JABBER_FIELD_MAP tlenFieldOccupation[] = { { 12, _T("Other") }, { 0, NULL } }; -JABBER_FIELD_MAP tlenFieldPlan[] = { +TLEN_FIELD_MAP tlenFieldPlan[] = { { 1, _T("I'd like to go downtown") }, { 2, _T("I'd like to go to the cinema") }, { 3, _T("I'd like to take a walk") }, @@ -77,7 +77,7 @@ JABBER_FIELD_MAP tlenFieldPlan[] = { static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam); -static void InitComboBox(HWND hwndCombo, JABBER_FIELD_MAP *fieldMap) +static void InitComboBox(HWND hwndCombo, TLEN_FIELD_MAP *fieldMap) { int i, n; @@ -101,9 +101,9 @@ static void FetchField(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i return; GetDlgItemTextA(hwndDlg, idCtrl, text, sizeof(text)); if (text[0]) { - if ((localFieldName=JabberTextEncode(fieldName)) != NULL) { - if ((localText=JabberTextEncode(text)) != NULL) { - JabberStringAppend(str, strSize, "<%s>%s", localFieldName, localText, localFieldName); + if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { + if ((localText=TlenTextEncode(text)) != NULL) { + TlenStringAppend(str, strSize, "<%s>%s", localFieldName, localText, localFieldName); mir_free(localText); } mir_free(localFieldName); @@ -120,8 +120,8 @@ static void FetchCombo(HWND hwndDlg, UINT idCtrl, char *fieldName, char **str, i return; value = (int) SendDlgItemMessage(hwndDlg, idCtrl, CB_GETITEMDATA, SendDlgItemMessage(hwndDlg, idCtrl, CB_GETCURSEL, 0, 0), 0); if (value > 0) { - if ((localFieldName=JabberTextEncode(fieldName)) != NULL) { - JabberStringAppend(str, strSize, "<%s>%d", localFieldName, value, localFieldName); + if ((localFieldName=TlenTextEncode(fieldName)) != NULL) { + TlenStringAppend(str, strSize, "<%s>%d", localFieldName, value, localFieldName); mir_free(localFieldName); } } @@ -180,7 +180,7 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara DBVARIANT dbv; char *jid; int i; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; SetDlgItemText(hwndDlg, IDC_INFO_JID, _T("")); SetDlgItemText(hwndDlg, IDC_SUBSCRIPTION, _T("")); @@ -249,12 +249,12 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara i = db_get_w(data->hContact, data->proto->m_szModuleName, "PublicStatus", 0); CheckDlgButton(hwndDlg, IDC_PUBLICSTATUS, i); if (!db_get(data->hContact, data->proto->m_szModuleName, "jid", &dbv)) { - jid = JabberTextDecode(dbv.pszVal); + jid = TlenTextDecode(dbv.pszVal); SetDlgItemTextA(hwndDlg, IDC_INFO_JID, jid); mir_free(jid); jid = dbv.pszVal; if (data->proto->isOnline) { - if ((item=JabberListGetItemPtr(data->proto, LIST_ROSTER, jid)) != NULL) { + if ((item=TlenListGetItemPtr(data->proto, LIST_ROSTER, jid)) != NULL) { switch (item->subscription) { case SUB_BOTH: SetDlgItemText(hwndDlg, IDC_SUBSCRIPTION, TranslateT("both")); @@ -303,7 +303,7 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara if (LOWORD(wParam) == IDC_SAVE && HIWORD(wParam) == BN_CLICKED) { char *str = NULL; int strSize; - JabberStringAppend(&str, &strSize, "", JabberSerialNext(data->proto)); + TlenStringAppend(&str, &strSize, "", TlenSerialNext(data->proto)); FetchField(hwndDlg, IDC_FIRSTNAME, "first", &str, &strSize); FetchField(hwndDlg, IDC_LASTNAME, "last", &str, &strSize); FetchField(hwndDlg, IDC_NICKNAME, "nick", &str, &strSize); @@ -314,10 +314,10 @@ static INT_PTR CALLBACK TlenUserInfoDlgProc(HWND hwndDlg, UINT msg, WPARAM wPara FetchCombo(hwndDlg, IDC_OCCUPATION, "j", &str, &strSize); FetchField(hwndDlg, IDC_SCHOOL, "e", &str, &strSize); FetchCombo(hwndDlg, IDC_LOOKFOR, "r", &str, &strSize); - JabberStringAppend(&str, &strSize, "%d", IsDlgButtonChecked(hwndDlg, IDC_VOICECONVERSATIONS) ? 1 : 0); - JabberStringAppend(&str, &strSize, "%d", IsDlgButtonChecked(hwndDlg, IDC_PUBLICSTATUS) ? 1 : 0); - JabberStringAppend(&str, &strSize, ""); - JabberSend(data->proto, "%s", str); + TlenStringAppend(&str, &strSize, "%d", IsDlgButtonChecked(hwndDlg, IDC_VOICECONVERSATIONS) ? 1 : 0); + TlenStringAppend(&str, &strSize, "%d", IsDlgButtonChecked(hwndDlg, IDC_PUBLICSTATUS) ? 1 : 0); + TlenStringAppend(&str, &strSize, ""); + TlenSend(data->proto, "%s", str); mir_free(str); data->proto->GetInfo(NULL, 0); } diff --git a/protocols/Tlen/src/tlen_util.cpp b/protocols/Tlen/src/tlen_util.cpp index ea054d882d..6f13a7dd99 100644 --- a/protocols/Tlen/src/tlen_util.cpp +++ b/protocols/Tlen/src/tlen_util.cpp @@ -26,19 +26,19 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include #include -void JabberSerialInit(TlenProtocol *proto) +void TlenSerialInit(TlenProtocol *proto) { InitializeCriticalSection(&proto->csSerial); proto->serial = 0; } -void JabberSerialUninit(TlenProtocol *proto) +void TlenSerialUninit(TlenProtocol *proto) { DeleteCriticalSection(&proto->csSerial); } -unsigned int JabberSerialNext(TlenProtocol *proto) +unsigned int TlenSerialNext(TlenProtocol *proto) { unsigned int ret; @@ -50,7 +50,7 @@ unsigned int JabberSerialNext(TlenProtocol *proto) } -void JabberLog(TlenProtocol *proto, const char *fmt, ...) +void TlenLog(TlenProtocol *proto, const char *fmt, ...) { #ifdef ENABLE_LOGGING char *str; @@ -98,9 +98,9 @@ void JabberLog(TlenProtocol *proto, const char *fmt, ...) #endif } -// Caution: DO NOT use JabberSend() to send binary (non-string) data +// Caution: DO NOT use TlenSend() to send binary (non-string) data -int JabberSend(TlenProtocol *proto, const char *fmt, ...) +int TlenSend(TlenProtocol *proto, const char *fmt, ...) { char *str; int size; @@ -118,13 +118,13 @@ int JabberSend(TlenProtocol *proto, const char *fmt, ...) } va_end(vararg); - JabberLog(proto, "SEND:%s", str); + TlenLog(proto, "SEND:%s", str); size = (int)strlen(str); if (proto->threadData != NULL) { if (proto->threadData->useAES) { - result = JabberWsSendAES(proto, str, size, &proto->threadData->aes_out_context, proto->threadData->aes_out_iv); + result = TlenWsSendAES(proto, str, size, &proto->threadData->aes_out_context, proto->threadData->aes_out_iv); } else { - result = JabberWsSend(proto, proto->threadData->s, str, size); + result = TlenWsSend(proto, proto->threadData->s, str, size); } } LeaveCriticalSection(&proto->csSend); @@ -133,7 +133,7 @@ int JabberSend(TlenProtocol *proto, const char *fmt, ...) return result; } -char *JabberResourceFromJID(const char *jid2) +char *TlenResourceFromJID(const char *jid2) { char *p; char *nick; @@ -155,7 +155,7 @@ char *JabberResourceFromJID(const char *jid2) return nick; } -char *JabberNickFromJID(const char *jid2) +char *TlenNickFromJID(const char *jid2) { char *p; char *nick; @@ -177,7 +177,7 @@ char *JabberNickFromJID(const char *jid2) return nick; } -char *JabberLoginFromJID(const char *jid2) +char *TlenLoginFromJID(const char *jid2) { char *p; char *nick; @@ -198,18 +198,18 @@ char *JabberLoginFromJID(const char *jid2) return nick; } -char *JabberLocalNickFromJID(const char *jid) +char *TlenLocalNickFromJID(const char *jid) { char *p; char *localNick; - p = JabberNickFromJID(jid); - localNick = JabberTextDecode(p); + p = TlenNickFromJID(jid); + localNick = TlenTextDecode(p); mir_free(p); return localNick; } -char *JabberSha1(char *str) +char *TlenSha1(char *str) { mir_sha1_ctx sha; DWORD digest[5]; @@ -335,7 +335,7 @@ char * TlenGroupDecode(const char *str) { char *p, *q; if (str == NULL) return NULL; - p = q = JabberTextDecode(str); + p = q = TlenTextDecode(str); for (; *p != '\0'; p++) { if (*p == '/') { *p = '\\'; @@ -354,12 +354,12 @@ char * TlenGroupEncode(const char *str) *p = '/'; } } - p = JabberTextEncode(q); + p = TlenTextEncode(q); mir_free(q); return p; } -char *JabberTextEncode(const char *str) +char *TlenTextEncode(const char *str) { char *s1; @@ -369,7 +369,7 @@ char *JabberTextEncode(const char *str) return s1; } -char *JabberTextDecode(const char *str) +char *TlenTextDecode(const char *str) { char *s1; @@ -396,7 +396,7 @@ time_t TlenTimeToUTC(time_t time) { return time; } -time_t JabberIsoToUnixTime(char *stamp) +time_t TlenIsoToUnixTime(char *stamp) { struct tm timestamp; char date[9]; @@ -450,7 +450,7 @@ time_t JabberIsoToUnixTime(char *stamp) return (time_t) 0; } -void JabberStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) +void TlenStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) { va_list vararg; char *p; @@ -481,7 +481,7 @@ void JabberStringAppend(char **str, int *sizeAlloced, const char *fmt, ...) BOOL IsAuthorized(TlenProtocol *proto, const char *jid) { - JABBER_LIST_ITEM *item = JabberListGetItemPtr(proto, LIST_ROSTER, jid); + TLEN_LIST_ITEM *item = TlenListGetItemPtr(proto, LIST_ROSTER, jid); if (item != NULL) { return item->subscription == SUB_BOTH || item->subscription == SUB_FROM; } @@ -495,6 +495,6 @@ void TlenLogMessage(TlenProtocol *proto, HANDLE hContact, DWORD flags, const cha char *localMessage = (char *)mir_alloc(size); strcpy(localMessage, message); localMessage[size - 1] = '\0'; - JabberDBAddEvent(proto, hContact, EVENTTYPE_MESSAGE, flags, (PBYTE)message, (DWORD)size); + TlenDBAddEvent(proto, hContact, EVENTTYPE_MESSAGE, flags, (PBYTE)message, (DWORD)size); mir_free(localMessage); } diff --git a/protocols/Tlen/src/tlen_voice.cpp b/protocols/Tlen/src/tlen_voice.cpp index 4e9db3aa77..a0b2c7ccd6 100644 --- a/protocols/Tlen/src/tlen_voice.cpp +++ b/protocols/Tlen/src/tlen_voice.cpp @@ -72,7 +72,7 @@ static DWORD WINAPI TlenVoiceRecordingThreadProc(TLEN_VOICE_CONTROL *control) while (TRUE) { GetMessage(&msg,NULL,0,0); if (msg.message == MM_WIM_DATA) { -// JabberLog("recording thread running...%d", msg.message); +// TlenLog("recording thread running...%d", msg.message); hWaveIn = (HWAVEIN) msg.wParam; hWaveHdr = (WAVEHDR *) msg.lParam; waveInUnprepareHeader(hWaveIn, hWaveHdr, sizeof(WAVEHDR)); @@ -91,7 +91,7 @@ static DWORD WINAPI TlenVoiceRecordingThreadProc(TLEN_VOICE_CONTROL *control) } } control->isRunning = 0; - JabberLog(control->proto, "recording thread ended..."); + TlenLog(control->proto, "recording thread ended..."); return 0; } @@ -148,18 +148,18 @@ static int TlenVoicePlaybackStart(TLEN_VOICE_CONTROL *control) } } if (!waveOutGetDevCaps(iSelDev, &wic, sizeof(WAVEOUTCAPS))) { - JabberLog(control->proto, "Playback device ID #%u: %s\r\n", iSelDev, wic.szPname); + TlenLog(control->proto, "Playback device ID #%u: %s\r\n", iSelDev, wic.szPname); } mmres = waveOutOpen(&control->hWaveOut, iSelDev, &wfm, (DWORD) &TlenVoicePlaybackCallback, (DWORD) control, CALLBACK_FUNCTION); if (mmres != MMSYSERR_NOERROR) { - JabberLog(control->proto, "TlenVoiceStart FAILED!"); + TlenLog(control->proto, "TlenVoiceStart FAILED!"); return 1; } control->waveData = (short *)mir_alloc(control->waveHeadersNum * control->waveFrameSize * 2); memset(control->waveData, 0, control->waveHeadersNum * control->waveFrameSize * 2); control->waveHeaders = (WAVEHDR *)mir_alloc(control->waveHeadersNum * sizeof(WAVEHDR)); - JabberLog(control->proto, "TlenVoiceStart OK!"); + TlenLog(control->proto, "TlenVoiceStart OK!"); return 0; } @@ -215,14 +215,14 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) } } if (!waveInGetDevCaps(iSelDev, &wic, sizeof(WAVEINCAPS))) { - JabberLog(control->proto, "Recording device ID #%u: %s\r\n", iSelDev, wic.szPname); + TlenLog(control->proto, "Recording device ID #%u: %s\r\n", iSelDev, wic.szPname); } mmres = waveInOpen(&control->hWaveIn, iSelDev, &wfm, (DWORD) control->threadID, 0, CALLBACK_THREAD); // mmres = waveInOpen(&control->hWaveIn, 3, &wfm, (DWORD) &TlenVoiceRecordingCallback, (DWORD) control, CALLBACK_FUNCTION); if (mmres != MMSYSERR_NOERROR) { PostThreadMessage(control->threadID, WIM_CLOSE, 0, 0); - JabberLog(control->proto, "TlenVoiceStart FAILED %d!", mmres); + TlenLog(control->proto, "TlenVoiceStart FAILED %d!", mmres); return 1; } control->waveData = (short *)mir_alloc(control->waveHeadersNum * control->waveFrameSize * 2); @@ -236,7 +236,7 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) if (mmres != MMSYSERR_NOERROR) { waveInClose(control->hWaveIn); // PostThreadMessage(control->threadID, WIM_CLOSE, 0, 0); - JabberLog(control->proto, "TlenVoiceStart FAILED #2!"); + TlenLog(control->proto, "TlenVoiceStart FAILED #2!"); return 1; } } @@ -244,7 +244,7 @@ static int TlenVoiceRecordingStart(TLEN_VOICE_CONTROL *control) waveInAddBuffer(control->hWaveIn, &control->waveHeaders[i], sizeof(WAVEHDR)); } waveInStart(control->hWaveIn); - JabberLog(control->proto, "TlenVoiceRStart OK!"); + TlenLog(control->proto, "TlenVoiceRStart OK!"); return 0; } @@ -262,7 +262,7 @@ static TLEN_VOICE_CONTROL *TlenVoiceCreateVC(TlenProtocol *proto, int codec) static void TlenVoiceFreeVc(TLEN_VOICE_CONTROL *vc) { int i; - JabberLog(vc->proto, "-> TlenVoiceFreeVc"); + TlenLog(vc->proto, "-> TlenVoiceFreeVc"); vc->stopThread = 1; PostThreadMessage(vc->threadID, MM_WIM_CLOSE, 0, 0); while (vc->isRunning) { @@ -292,7 +292,7 @@ static void TlenVoiceFreeVc(TLEN_VOICE_CONTROL *vc) if (vc->waveData) mir_free(vc->waveData); if (vc->waveHeaders) mir_free(vc->waveHeaders); if (vc->gsmstate) gsm_release(vc->gsmstate); - JabberLog(vc->proto, "<- TlenVoiceFreeVc"); + TlenLog(vc->proto, "<- TlenVoiceFreeVc"); mir_free(vc); } @@ -313,9 +313,9 @@ static void TlenVoiceCrypt(char *buffer, int len) void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) { NETLIBOPENCONNECTION nloc; - JABBER_SOCKET s; + TLEN_SOCKET s; - JabberLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); + TlenLog(ft->proto, "Thread started: type=file_receive server='%s' port='%d'", ft->hostName, ft->wPort); nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = ft->hostName; nloc.wPort = ft->wPort; @@ -325,7 +325,7 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) s = (HANDLE) CallService(MS_NETLIB_OPENCONNECTION, (WPARAM) ft->proto->hNetlibUser, (LPARAM) &nloc); if (s != NULL) { ft->s = s; - JabberLog(ft->proto, "Entering file receive loop"); + TlenLog(ft->proto, "Entering file receive loop"); TlenP2PEstablishOutgoingConnection(ft, FALSE); if (ft->state != FT_ERROR) { ft->proto->playbackControl = NULL; @@ -344,7 +344,7 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) } ft->s = NULL; } else { - JabberLog(ft->proto, "Connection failed - receiving as server"); + TlenLog(ft->proto, "Connection failed - receiving as server"); ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection; s = TlenP2PListen(ft); if (s != NULL) { @@ -356,39 +356,39 @@ void __cdecl TlenVoiceReceiveThread(TLEN_FILE_TRANSFER *ft) ft->hFileEvent = hEvent; ft->currentFile = 0; ft->state = FT_CONNECTING; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - JabberLog(ft->proto, "Waiting for the file to be received..."); + TlenLog(ft->proto, "Waiting for the file to be received..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - JabberLog(ft->proto, "Finish all files"); + TlenLog(ft->proto, "Finish all files"); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; } } - JabberListRemove(ft->proto, LIST_VOICE, ft->iqId); + TlenListRemove(ft->proto, LIST_VOICE, ft->iqId); if (ft->state == FT_DONE) { SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Finished...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); } else { char *nick; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); } - JabberLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); + TlenLog(ft->proto, "Thread ended: type=file_receive server='%s'", ft->hostName); TlenP2PFreeFileTransfer(ft); } -static void TlenVoiceReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) +static void TlenVoiceReceivingConnection(TLEN_SOCKET hConnection, DWORD dwRemoteIP, void * pExtra) { - JABBER_SOCKET slisten; + TLEN_SOCKET slisten; TLEN_FILE_TRANSFER *ft; TlenProtocol *proto = (TlenProtocol *)pExtra; @@ -396,8 +396,8 @@ static void TlenVoiceReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemo if (ft != NULL) { slisten = ft->s; ft->s = hConnection; - JabberLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); - JabberLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); + TlenLog(ft->proto, "Set ft->s to %d (saving %d)", hConnection, slisten); + TlenLog(ft->proto, "Entering send loop for this file connection... (ft->s is hConnection)"); proto->playbackControl = NULL; proto->recordingControl = TlenVoiceCreateVC(proto, 3); proto->recordingControl->ft = ft; @@ -415,9 +415,9 @@ static void TlenVoiceReceivingConnection(JABBER_SOCKET hConnection, DWORD dwRemo // ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); } - JabberLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); + TlenLog(ft->proto, "Closing connection for this file transfer... (ft->s is now hBind)"); ft->s = slisten; - JabberLog(ft->proto, "ft->s is restored to %d", ft->s); + TlenLog(ft->proto, "ft->s is restored to %d", ft->s); } Netlib_CloseHandle(hConnection); if (ft != NULL && ft->hFileEvent != NULL) @@ -533,41 +533,41 @@ static void TlenVoiceReceiveParse(TLEN_FILE_TRANSFER *ft) void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) { - JABBER_SOCKET s = NULL; + TLEN_SOCKET s = NULL; HANDLE hEvent; char *nick; - JabberLog(ft->proto, "Thread started: type=voice_send"); + TlenLog(ft->proto, "Thread started: type=voice_send"); ft->pfnNewConnectionV2 = TlenVoiceReceivingConnection; s = TlenP2PListen(ft); if (s != NULL) { SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Waiting for connection...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_CONNECTING, ft, 0); ft->s = s; - //JabberLog("ft->s = %d", s); - //JabberLog("fileCount = %d", ft->fileCount); + //TlenLog("ft->s = %d", s); + //TlenLog("fileCount = %d", ft->fileCount); hEvent = CreateEvent(NULL, FALSE, FALSE, NULL); ft->hFileEvent = hEvent; ft->currentFile = 0; ft->state = FT_CONNECTING; - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId, ft->localName, ft->wLocalPort); mir_free(nick); - JabberLog(ft->proto, "Waiting for the voice data to be sent..."); + TlenLog(ft->proto, "Waiting for the voice data to be sent..."); WaitForSingleObject(hEvent, INFINITE); ft->hFileEvent = NULL; CloseHandle(hEvent); - JabberLog(ft->proto, "Finish voice"); + TlenLog(ft->proto, "Finish voice"); Netlib_CloseHandle(s); ft->s = NULL; - JabberLog(ft->proto, "ft->s is NULL"); + TlenLog(ft->proto, "ft->s is NULL"); if (ft->state == FT_SWITCH) { NETLIBOPENCONNECTION nloc; - JABBER_SOCKET s; - JabberLog(ft->proto, "Sending as client..."); + TLEN_SOCKET s; + TlenLog(ft->proto, "Sending as client..."); ft->state = FT_CONNECTING; nloc.cbSize = NETLIBOPENCONNECTION_V1_SIZE;//sizeof(NETLIBOPENCONNECTION); nloc.szHost = ft->hostName; @@ -580,7 +580,7 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) ft->s = s; TlenP2PEstablishOutgoingConnection(ft, FALSE); if (ft->state != FT_ERROR) { - JabberLog(ft->proto, "Entering send loop for this file connection..."); + TlenLog(ft->proto, "Entering send loop for this file connection..."); ft->proto->playbackControl = NULL; ft->proto->recordingControl = TlenVoiceCreateVC(ft->proto, 3); ft->proto->recordingControl->ft = ft; @@ -589,20 +589,20 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) TlenVoiceReceiveParse(ft); } } - JabberLog(ft->proto, "Closing connection for this file transfer... "); + TlenLog(ft->proto, "Closing connection for this file transfer... "); Netlib_CloseHandle(s); } else { ft->state = FT_ERROR; } } } else { - JabberLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); + TlenLog(ft->proto, "Cannot allocate port to bind for file server thread, thread ended."); ft->state = FT_ERROR; } - JabberListRemove(ft->proto, LIST_VOICE, ft->iqId); + TlenListRemove(ft->proto, LIST_VOICE, ft->iqId); switch (ft->state) { case FT_DONE: - JabberLog(ft->proto, "Finish successfully"); + TlenLog(ft->proto, "Finish successfully"); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Finished...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_SUCCESS, ft, 0); break; @@ -611,15 +611,15 @@ void __cdecl TlenVoiceSendingThread(TLEN_FILE_TRANSFER *ft) //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_DENIED, ft, 0); break; default: // FT_ERROR: - nick = JabberNickFromJID(ft->jid); - JabberSend(ft->proto, "", nick, ft->iqId); + nick = TlenNickFromJID(ft->jid); + TlenSend(ft->proto, "", nick, ft->iqId); mir_free(nick); - JabberLog(ft->proto, "Finish with errors"); + TlenLog(ft->proto, "Finish with errors"); SetDlgItemText(ft->proto->voiceDlgHWND, IDC_STATUS, TranslateT("...Error...")); //ProtoBroadcastAck(ft->proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); break; } - JabberLog(ft->proto, "Thread ended: type=voice_send"); + TlenLog(ft->proto, "Thread ended: type=voice_send"); TlenP2PFreeFileTransfer(ft); } @@ -664,18 +664,18 @@ static void TlenVoiceSendParse(TLEN_FILE_TRANSFER *ft) int TlenVoiceCancelAll(TlenProtocol *proto) { - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; HANDLE hEvent; int i = 0; - while ((i=JabberListFindNext(proto, LIST_VOICE, 0)) >=0 ) { - if ((item=JabberListGetItemPtrFromIndex(proto, i)) != NULL) { + while ((i=TlenListFindNext(proto, LIST_VOICE, 0)) >=0 ) { + if ((item=TlenListGetItemPtrFromIndex(proto, i)) != NULL) { TLEN_FILE_TRANSFER *ft = item->ft; - JabberListRemoveByIndex(proto, i); + TlenListRemoveByIndex(proto, i); if (ft != NULL) { if (ft->s) { //ProtoBroadcastAck(proto->m_szModuleName, ft->hContact, ACKTYPE_FILE, ACKRESULT_FAILED, ft, 0); - JabberLog(proto, "Closing ft->s = %d", ft->s); + TlenLog(proto, "Closing ft->s = %d", ft->s); ft->state = FT_ERROR; Netlib_CloseHandle(ft->s); ft->s = NULL; @@ -685,7 +685,7 @@ int TlenVoiceCancelAll(TlenProtocol *proto) SetEvent(hEvent); } } else { - JabberLog(proto, "freeing (V) ft struct"); + TlenLog(proto, "freeing (V) ft struct"); TlenP2PFreeFileTransfer(ft); } } @@ -701,7 +701,7 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM lParam) { HANDLE hContact; DBVARIANT dbv; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; TLEN_FILE_TRANSFER *ft; if (!isOnline) return 1; @@ -709,13 +709,13 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM lParam) if ((hContact=(HANDLE) wParam) != NULL) { if (!db_get(hContact, m_szModuleName, "jid", &dbv)) { char serialId[32]; - mir_snprintf(serialId, SIZEOF(serialId), "%d", JabberSerialNext(this)); - if ((item = JabberListAdd(this, LIST_VOICE, serialId)) != NULL) { + mir_snprintf(serialId, SIZEOF(serialId), "%d", TlenSerialNext(this)); + if ((item = TlenListAdd(this, LIST_VOICE, serialId)) != NULL) { ft = TlenFileCreateFT(this, dbv.pszVal); ft->iqId = mir_strdup(serialId); item->ft = ft; TlenVoiceStart(ft, 2); - JabberSend(ft->proto, "", ft->jid, serialId); + TlenSend(ft->proto, "", ft->jid, serialId); } db_free(&dbv); } @@ -724,8 +724,8 @@ INT_PTR TlenProtocol::VoiceContactMenuHandleVoice(WPARAM wParam, LPARAM lParam) } int TlenVoiceIsInUse(TlenProtocol *proto) { - if (JabberListFindNext(proto, LIST_VOICE, 0) >= 0 || proto->voiceDlgHWND != NULL) { - JabberLog(proto, "voice in use ? %d", proto->voiceDlgHWND); + if (TlenListFindNext(proto, LIST_VOICE, 0) >= 0 || proto->voiceDlgHWND != NULL) { + TlenLog(proto, "voice in use ? %d", proto->voiceDlgHWND); return 1; } return 0; @@ -934,13 +934,13 @@ static void __cdecl TlenVoiceDlgThread(void *ptr) int TlenVoiceStart(TLEN_FILE_TRANSFER *ft, int mode) { - JabberLog(ft->proto, "starting voice %d", mode); + TlenLog(ft->proto, "starting voice %d", mode); if (mode == 0) { - JabberForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, ft); + TlenForkThread((void (__cdecl *)(void*))TlenVoiceReceiveThread, 0, ft); } else if (mode == 1) { - JabberForkThread((void (__cdecl *)(void*))TlenVoiceSendingThread, 0, ft); + TlenForkThread((void (__cdecl *)(void*))TlenVoiceSendingThread, 0, ft); } else { - JabberForkThread((void (__cdecl *)(void*))TlenVoiceDlgThread, 0, ft); + TlenForkThread((void (__cdecl *)(void*))TlenVoiceDlgThread, 0, ft); } return 0; } @@ -953,7 +953,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) if (!db_get(NULL, proto->m_szModuleName, "LoginServer", &dbv)) { mir_snprintf(jid, sizeof(jid), "%s@%s", id, dbv.pszVal); db_free(&dbv); - if ((hContact=JabberHContactFromJID(proto, jid)) != NULL) { + if ((hContact=TlenHContactFromJID(proto, jid)) != NULL) { return mir_strdup((char *) CallService(MS_CLIST_GETCONTACTDISPLAYNAME, (WPARAM) hContact, 0)); } } @@ -962,7 +962,7 @@ static char *getDisplayName(TlenProtocol *proto, const char *id) typedef struct { TlenProtocol *proto; - JABBER_LIST_ITEM *item; + TLEN_LIST_ITEM *item; }ACCEPTDIALOGDATA; static INT_PTR CALLBACK TlenVoiceAcceptDlgProc(HWND hwndDlg, UINT msg, WPARAM wParam, LPARAM lParam) @@ -1004,21 +1004,21 @@ static void __cdecl TlenVoiceAcceptDlgThread(void *ptr) data->item->ft = TlenFileCreateFT(data->proto, data->item->nick); data->item->ft->iqId = mir_strdup(data->item->jid); TlenVoiceStart(data->item->ft, 2); - JabberSend(data->proto, "", data->item->nick, data->item->jid); + TlenSend(data->proto, "", data->item->nick, data->item->jid); } else { if (data->proto->isOnline) { - JabberSend(data->proto, "", data->item->nick, data->item->jid); + TlenSend(data->proto, "", data->item->nick, data->item->jid); } - JabberListRemove(data->proto, LIST_VOICE, data->item->jid); + TlenListRemove(data->proto, LIST_VOICE, data->item->jid); } mir_free(data); } int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) { - JABBER_LIST_ITEM * item; + TLEN_LIST_ITEM * item; if (!TlenVoiceIsInUse(proto)) { - if ((item = JabberListAdd(proto, LIST_VOICE, id)) != NULL) { + if ((item = TlenListAdd(proto, LIST_VOICE, id)) != NULL) { int ask, ignore, voiceChatPolicy; ask = TRUE; ignore = FALSE; @@ -1056,21 +1056,21 @@ int TlenVoiceAccept(TlenProtocol *proto, const char *id, const char *from) } if (ignore) { if (proto->isOnline) { - JabberSend(proto, "", from, id); + TlenSend(proto, "", from, id); } - JabberListRemove(proto, LIST_VOICE, id); + TlenListRemove(proto, LIST_VOICE, id); } else { item->nick = mir_strdup(from); if (ask) { ACCEPTDIALOGDATA *data = (ACCEPTDIALOGDATA *)mir_alloc(sizeof(ACCEPTDIALOGDATA)); data->proto = proto; data->item = item; - JabberForkThread((void (__cdecl *)(void*))TlenVoiceAcceptDlgThread, 0, data); + TlenForkThread((void (__cdecl *)(void*))TlenVoiceAcceptDlgThread, 0, data); } else if (proto->isOnline) { item->ft = TlenFileCreateFT(proto, from); item->ft->iqId = mir_strdup(id); TlenVoiceStart(item->ft, 2); - JabberSend(proto, "", item->nick, item->jid); + TlenSend(proto, "", item->nick, item->jid); } } return 1; diff --git a/protocols/Tlen/src/tlen_ws.cpp b/protocols/Tlen/src/tlen_ws.cpp index f1931d5650..bbd1fb7898 100644 --- a/protocols/Tlen/src/tlen_ws.cpp +++ b/protocols/Tlen/src/tlen_ws.cpp @@ -23,7 +23,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen.h" -BOOL JabberWsInit(TlenProtocol *proto) +BOOL TlenWsInit(TlenProtocol *proto) { NETLIBUSER nlu = {0}; NETLIBUSERSETTINGS nlus = {0}; @@ -48,7 +48,7 @@ BOOL JabberWsInit(TlenProtocol *proto) return (proto->hNetlibUser != NULL)?TRUE:FALSE; } -void JabberWsUninit(TlenProtocol *proto) +void TlenWsUninit(TlenProtocol *proto) { if (proto->hNetlibUser != NULL) Netlib_CloseHandle(proto->hNetlibUser); if (proto->hFileNetlibUser != NULL) Netlib_CloseHandle(proto->hFileNetlibUser); @@ -56,7 +56,7 @@ void JabberWsUninit(TlenProtocol *proto) proto->hFileNetlibUser = NULL; } -JABBER_SOCKET JabberWsConnect(TlenProtocol *proto, char *host, WORD port) +TLEN_SOCKET TlenWsConnect(TlenProtocol *proto, char *host, WORD port) { NETLIBOPENCONNECTION nloc = {0}; @@ -69,33 +69,33 @@ JABBER_SOCKET JabberWsConnect(TlenProtocol *proto, char *host, WORD port) } -int JabberWsSend(TlenProtocol *proto, JABBER_SOCKET s, char *data, int datalen) +int TlenWsSend(TlenProtocol *proto, TLEN_SOCKET s, char *data, int datalen) { int len; if ((len=Netlib_Send(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT)) == SOCKET_ERROR || len != datalen) { - JabberLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); + TlenLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); return FALSE; } return TRUE; } -int JabberWsRecv(TlenProtocol *proto, JABBER_SOCKET s, char *data, long datalen) +int TlenWsRecv(TlenProtocol *proto, TLEN_SOCKET s, char *data, long datalen) { int ret; ret = Netlib_Recv(s, data, datalen, /*MSG_NODUMP|*/MSG_DUMPASTEXT); if (ret == SOCKET_ERROR) { - JabberLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); + TlenLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); return 0; } if (ret == 0) { - JabberLog(proto, "Connection closed gracefully"); + TlenLog(proto, "Connection closed gracefully"); return 0; } return ret; } -int JabberWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes_ctx, unsigned char *aes_iv) +int TlenWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *aes_ctx, unsigned char *aes_iv) { int len, sendlen; unsigned char aes_input[16]; @@ -115,9 +115,9 @@ int JabberWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *a len += 16; } if (len > 0) { - JabberLog(proto, "Sending %d bytes", len); + TlenLog(proto, "Sending %d bytes", len); if ((sendlen=Netlib_Send(proto->threadData->s, (char *)aes_output, len, MSG_NODUMP)) == SOCKET_ERROR || len != sendlen) { - JabberLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); + TlenLog(proto, "Netlib_Send() failed, error=%d", WSAGetLastError()); return FALSE; } } @@ -125,7 +125,7 @@ int JabberWsSendAES(TlenProtocol *proto, char *data, int datalen, aes_context *a return TRUE; } -int JabberWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *aes_ctx, unsigned char *aes_iv) +int TlenWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context *aes_ctx, unsigned char *aes_iv) { int ret, len = 0, maxlen = datalen; unsigned char aes_input[16]; @@ -136,11 +136,11 @@ int JabberWsRecvAES(TlenProtocol *proto, char *data, long datalen, aes_context * for (maxlen = maxlen & ~0xF; maxlen != 0; maxlen = maxlen & 0xF) { ret = Netlib_Recv(proto->threadData->s, data, maxlen, MSG_NODUMP); if (ret == SOCKET_ERROR) { - JabberLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); + TlenLog(proto, "Netlib_Recv() failed, error=%d", WSAGetLastError()); return 0; } if (ret == 0) { - JabberLog(proto, "Connection closed gracefully"); + TlenLog(proto, "Connection closed gracefully"); return 0; } data += ret; diff --git a/protocols/Tlen/src/tlen_xml.cpp b/protocols/Tlen/src/tlen_xml.cpp index 2364bfcadd..2c86119649 100644 --- a/protocols/Tlen/src/tlen_xml.cpp +++ b/protocols/Tlen/src/tlen_xml.cpp @@ -24,10 +24,10 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "tlen.h" #include -static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *elemText, char *elemAttr); -static void JabberXmlRemoveChild(XmlNode *node, XmlNode *child); +static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *elemText, char *elemAttr); +static void TlenXmlRemoveChild(XmlNode *node, XmlNode *child); -void JabberXmlInitState(XmlState *xmlState) +void TlenXmlInitState(XmlState *xmlState) { if (xmlState == NULL) return; xmlState->root.name = NULL; @@ -50,18 +50,18 @@ void JabberXmlInitState(XmlState *xmlState) xmlState->userdata2_close = NULL; } -void JabberXmlDestroyState(XmlState *xmlState) +void TlenXmlDestroyState(XmlState *xmlState) { int i; XmlNode *node; if (xmlState == NULL) return; - // Note: cannot use JabberXmlFreeNode() to free xmlState->root + // Note: cannot use TlenXmlFreeNode() to free xmlState->root // because it will do mir_free(xmlState->root) which is not freeable. node = &(xmlState->root); // Free all children first for (i=0; inumChild; i++) - JabberXmlFreeNode(node->child[i]); + TlenXmlFreeNode(node->child[i]); if (node->child) mir_free(node->child); // Free all attributes for (i=0; inumAttr; i++) { @@ -75,7 +75,7 @@ void JabberXmlDestroyState(XmlState *xmlState) if (node->name) mir_free(node->name); } -BOOL JabberXmlSetCallback(XmlState *xmlState, int depth, XmlElemType type, void (*callback)(XmlNode*, void*), void *userdata) +BOOL TlenXmlSetCallback(XmlState *xmlState, int depth, XmlElemType type, void (*callback)(XmlNode*, void*), void *userdata) { if (depth == 1 && type == ELEM_OPEN) { xmlState->callback1_open = callback; @@ -101,7 +101,7 @@ BOOL JabberXmlSetCallback(XmlState *xmlState, int depth, XmlElemType type, void #define TAG_MAX_LEN 50 #define ATTR_MAX_LEN 1024 -int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) +int TlenXmlParse(XmlState *xmlState, char *buffer, int datalen) { char *p, *q, *r, *eob; char *str; @@ -120,7 +120,7 @@ int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) if (q < eob) { // found closing bracket for (r=p+1; *r != '>' && *r != ' ' && *r != '\t'; r++); if (r-(p+1) > TAG_MAX_LEN) { -// JabberLog("TAG_MAX_LEN too small, ignore current tag"); +// TlenLog("TAG_MAX_LEN too small, ignore current tag"); } else { if (*(p+1) == '/') { // closing tag @@ -142,7 +142,7 @@ int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) } for (;r ATTR_MAX_LEN) { -// JabberLog("ATTR_MAX_LEN too small, ignore current tag"); +// TlenLog("ATTR_MAX_LEN too small, ignore current tag"); } else { strncpy(attr, r, q-r); @@ -152,7 +152,7 @@ int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) } else attr[q-r] = '\0'; - JabberXmlProcessElem(xmlState, elemType, tag, attr); + TlenXmlProcessElem(xmlState, elemType, tag, attr); } } num += (q-p+1); @@ -171,7 +171,7 @@ int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) str = (char *) mir_alloc(q-p+1); strncpy(str, p, q-p); str[q-p] = '\0'; - JabberXmlProcessElem(xmlState, ELEM_TEXT, str, NULL); + TlenXmlProcessElem(xmlState, ELEM_TEXT, str, NULL); mir_free(str); num += (q-p); p = q; @@ -184,7 +184,7 @@ int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen) return num; } -static void JabberXmlParseAttr(XmlNode *node, char *text) +static void TlenXmlParseAttr(XmlNode *node, char *text) { char *kstart, *vstart; int klen, vlen; @@ -269,7 +269,7 @@ static void JabberXmlParseAttr(XmlNode *node, char *text) } } -static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *elemText, char *elemAttr) +static BOOL TlenXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char *elemText, char *elemAttr) { XmlNode *node, *parentNode, *n; //BOOL activateCallback = FALSE; @@ -278,7 +278,7 @@ static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char if (elemText == NULL) return FALSE; if (elemType == ELEM_OPEN && !strcmp(elemText, "?xml")) { -// JabberLog("XML: skip tag"); +// TlenLog("XML: skip tag"); return TRUE; } @@ -314,7 +314,7 @@ static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char n->child = NULL; n->numAttr = n->maxNumAttr = 0; n->attr = NULL; - JabberXmlParseAttr(n, attr); + TlenXmlParseAttr(n, attr); n->text = NULL; if (n->depth == 1 && xmlState->callback1_open != NULL) (*(xmlState->callback1_open))(n, xmlState->userdata1_open); @@ -335,15 +335,15 @@ static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char n->child = NULL; n->numAttr = n->maxNumAttr = 0; n->attr = NULL; - JabberXmlParseAttr(n, attr); + TlenXmlParseAttr(n, attr); n->text = NULL; if (n->depth == 1 && xmlState->callback1_close != NULL) { (*(xmlState->callback1_close))(n, xmlState->userdata1_close); - JabberXmlRemoveChild(node, n); + TlenXmlRemoveChild(node, n); } if (n->depth == 2 && xmlState->callback2_close != NULL) { (*xmlState->callback2_close)(n, xmlState->userdata2_close); - JabberXmlRemoveChild(node, n); + TlenXmlRemoveChild(node, n); } break; case ELEM_CLOSE: @@ -351,16 +351,16 @@ static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char node->state = NODE_CLOSE; if (node->depth == 1 && xmlState->callback1_close != NULL) { (*(xmlState->callback1_close))(node, xmlState->userdata1_close); - JabberXmlRemoveChild(parentNode, node); + TlenXmlRemoveChild(parentNode, node); } if (node->depth == 2 && xmlState->callback2_close != NULL) { (*xmlState->callback2_close)(node, xmlState->userdata2_close); - JabberXmlRemoveChild(parentNode, node); + TlenXmlRemoveChild(parentNode, node); } mir_free(text); } else { -// JabberLog("XML: Closing without opening tag", text); +// TlenLog("XML: Closing without opening tag", text); mir_free(text); if (attr) mir_free(attr); return FALSE; @@ -380,7 +380,7 @@ static BOOL JabberXmlProcessElem(XmlState *xmlState, XmlElemType elemType, char return TRUE; } -char *JabberXmlGetAttrValue(XmlNode *node, char *key) +char *TlenXmlGetAttrValue(XmlNode *node, char *key) { int i; @@ -393,12 +393,12 @@ char *JabberXmlGetAttrValue(XmlNode *node, char *key) return NULL; } -XmlNode *JabberXmlGetChild(XmlNode *node, char *tag) +XmlNode *TlenXmlGetChild(XmlNode *node, char *tag) { - return JabberXmlGetNthChild(node, tag, 1); + return TlenXmlGetNthChild(node, tag, 1); } -XmlNode *JabberXmlGetNthChild(XmlNode *node, char *tag, int nth) +XmlNode *TlenXmlGetNthChild(XmlNode *node, char *tag, int nth) { int i, num; @@ -416,7 +416,7 @@ XmlNode *JabberXmlGetNthChild(XmlNode *node, char *tag, int nth) return NULL; } -XmlNode *JabberXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrKey, char *attrValue) +XmlNode *TlenXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrKey, char *attrValue) { int i; char *str; @@ -425,7 +425,7 @@ XmlNode *JabberXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *att return NULL; for (i=0; inumChild; i++) { if (node->child[i]->name && !strcmp(tag, node->child[i]->name)) { - if ((str=JabberXmlGetAttrValue(node->child[i], attrKey)) != NULL) + if ((str=TlenXmlGetAttrValue(node->child[i], attrKey)) != NULL) if (!strcmp(str, attrValue)) return node->child[i]; } @@ -433,7 +433,7 @@ XmlNode *JabberXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *att return NULL; } -static void JabberXmlRemoveChild(XmlNode *node, XmlNode *child) +static void TlenXmlRemoveChild(XmlNode *node, XmlNode *child) { int i; @@ -446,18 +446,18 @@ static void JabberXmlRemoveChild(XmlNode *node, XmlNode *child) for (++i; inumChild; i++) node->child[i-1] = node->child[i]; node->numChild--; - JabberXmlFreeNode(child); + TlenXmlFreeNode(child); } } -void JabberXmlFreeNode(XmlNode *node) +void TlenXmlFreeNode(XmlNode *node) { int i; if (node == NULL) return; // Free all children first for (i=0; inumChild; i++) - JabberXmlFreeNode(node->child[i]); + TlenXmlFreeNode(node->child[i]); if (node->child) mir_free(node->child); // Free all attributes for (i=0; inumAttr; i++) { @@ -473,7 +473,7 @@ void JabberXmlFreeNode(XmlNode *node) mir_free(node); } -XmlNode *JabberXmlCopyNode(XmlNode *node) +XmlNode *TlenXmlCopyNode(XmlNode *node) { XmlNode *n; int i; @@ -497,7 +497,7 @@ XmlNode *JabberXmlCopyNode(XmlNode *node) if (node->numChild > 0) { n->child = (XmlNode **) mir_alloc(node->numChild*sizeof(XmlNode *)); for (i=0; inumChild; i++) - n->child[i] = JabberXmlCopyNode(node->child[i]); + n->child[i] = TlenXmlCopyNode(node->child[i]); } else n->child = NULL; @@ -514,7 +514,7 @@ XmlNode *JabberXmlCopyNode(XmlNode *node) return n; } -XmlNode *JabberXmlCreateNode(char *name) +XmlNode *TlenXmlCreateNode(char *name) { XmlNode *n; @@ -527,7 +527,7 @@ XmlNode *JabberXmlCreateNode(char *name) return n; } -void JabberXmlAddAttr(XmlNode *n, char *name, char *value) +void TlenXmlAddAttr(XmlNode *n, char *name, char *value) { int i; @@ -542,7 +542,7 @@ void JabberXmlAddAttr(XmlNode *n, char *name, char *value) n->attr[i]->value = mir_strdup(value); } -XmlNode *JabberXmlAddChild(XmlNode *n, char *name) +XmlNode *TlenXmlAddChild(XmlNode *n, char *name) { int i; @@ -558,7 +558,7 @@ XmlNode *JabberXmlAddChild(XmlNode *n, char *name) return n->child[i]; } -void JabberXmlAddText(XmlNode *n, char *text) +void TlenXmlAddText(XmlNode *n, char *text) { if (n != NULL && text != NULL) { if (n->text) mir_free(n->text); diff --git a/protocols/Tlen/src/tlen_xml.h b/protocols/Tlen/src/tlen_xml.h index 165a8fadc5..9b5a078149 100644 --- a/protocols/Tlen/src/tlen_xml.h +++ b/protocols/Tlen/src/tlen_xml.h @@ -21,8 +21,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#ifndef _JABBER_XML_H_ -#define _JABBER_XML_H_ +#ifndef _TLEN_XML_H_ +#define _TLEN_XML_H_ typedef enum { ELEM_OPEN, ELEM_CLOSE, ELEM_OPENCLOSE, ELEM_TEXT } XmlElemType; typedef enum { NODE_OPEN, NODE_CLOSE } XmlNodeType; @@ -59,21 +59,21 @@ typedef struct tagXmlState { void *userdata2_close; } XmlState; -void JabberXmlInitState(XmlState *xmlState); -void JabberXmlDestroyState(XmlState *xmlState); -BOOL JabberXmlSetCallback(XmlState *xmlState, int depth, XmlElemType type, void (*callback)(XmlNode*, void*), void *userdata); -int JabberXmlParse(XmlState *xmlState, char *buffer, int datalen); -char *JabberXmlGetAttrValue(XmlNode *node, char *key); -XmlNode *JabberXmlGetChild(XmlNode *node, char *tag); -XmlNode *JabberXmlGetNthChild(XmlNode *node, char *tag, int nth); -XmlNode *JabberXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrKey, char *attrValue); -void JabberXmlFreeNode(XmlNode *node); -XmlNode *JabberXmlCopyNode(XmlNode *node); +void TlenXmlInitState(XmlState *xmlState); +void TlenXmlDestroyState(XmlState *xmlState); +BOOL TlenXmlSetCallback(XmlState *xmlState, int depth, XmlElemType type, void (*callback)(XmlNode*, void*), void *userdata); +int TlenXmlParse(XmlState *xmlState, char *buffer, int datalen); +char *TlenXmlGetAttrValue(XmlNode *node, char *key); +XmlNode *TlenXmlGetChild(XmlNode *node, char *tag); +XmlNode *TlenXmlGetNthChild(XmlNode *node, char *tag, int nth); +XmlNode *TlenXmlGetChildWithGivenAttrValue(XmlNode *node, char *tag, char *attrKey, char *attrValue); +void TlenXmlFreeNode(XmlNode *node); +XmlNode *TlenXmlCopyNode(XmlNode *node); -XmlNode *JabberXmlCreateNode(char *name); -void JabberXmlAddAttr(XmlNode *n, char *name, char *value); -XmlNode *JabberXmlAddChild(XmlNode *n, char *name); -void JabberXmlAddText(XmlNode *n, char *text); +XmlNode *TlenXmlCreateNode(char *name); +void TlenXmlAddAttr(XmlNode *n, char *name, char *value); +XmlNode *TlenXmlAddChild(XmlNode *n, char *name); +void TlenXmlAddText(XmlNode *n, char *text); #endif -- cgit v1.2.3