diff options
author | Kirill Volinsky <mataes2007@gmail.com> | 2013-08-19 07:37:30 +0000 |
---|---|---|
committer | Kirill Volinsky <mataes2007@gmail.com> | 2013-08-19 07:37:30 +0000 |
commit | b81bfbf62c6a3e2a977167fd041a989f609b16ea (patch) | |
tree | 4c9b2d18bff423d6266d7f9fe7a97bc8842b9d5e /protocols/Tlen/src/tlen_thread.cpp | |
parent | 36d3f260e6d6e3bbf665ad148b2bd2f325d7f87d (diff) |
replace jabber to tlen
git-svn-id: http://svn.miranda-ng.org/main/trunk@5742 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen/src/tlen_thread.cpp')
-rw-r--r-- | protocols/Tlen/src/tlen_thread.cpp | 524 |
1 files changed, 262 insertions, 262 deletions
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, "<s s='1' v='9' t='06000106'>");
+ TlenSend(info->proto, "<s s='1' v='9' t='06000106'>");
} else {
- JabberSend(info->proto, "<s v='3'>");
+ TlenSend(info->proto, "<s v='3'>");
}
- 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, "<iq type='set' id='"JABBER_IQID"%d'><query xmlns='jabber:iq:auth'><username>%s</username><digest>%s</digest><resource>t</resource><host>tlen.pl</host></query></iq>", 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, "<iq type='set' id='"TLEN_IQID"%d'><query xmlns='tlen:iq:auth'><username>%s</username><digest>%s</digest><resource>t</resource><host>tlen.pl</host></query></iq>", 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, "<cipher k1='%s' k2='%s'/>", aes_key_str, aes_iv_str);
+ TlenSend(info->proto, "<cipher k1='%s' k2='%s'/>", 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 <message/> <presence/> <iq/> <f/> <w/> <m/> <n/> <p/> <v/> <cipher/> and <avatar/> allowed)");
+ TlenLog(info->proto, "Invalid top-level tag (only <message/> <presence/> <iq/> <f/> <w/> <m/> <n/> <p/> <v/> <cipher/> and <avatar/> allowed)");
}
static void TlenProcessCipher(XmlNode *node, ThreadData *info)
{
char *type;
- type=JabberXmlGetAttrValue(node, "type");
+ type=TlenXmlGetAttrValue(node, "type");
info->useAES = TRUE;
- JabberSend(info->proto, "<cipher type='ok'/>");
+ TlenSend(info->proto, "<cipher type='ok'/>");
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, "<message to='%s' type='iq'><iq type='result'><query xmlns='jabber:iq:version'><name>%s</name><version>%s</version><os>%s</os></query></iq></message>", from, mver?mver:"", version?version:"", os?os:"" );
+ mver = TlenTextEncode( mversion );
+ TlenSend( proto, "<message to='%s' type='iq'><iq type='result'><query xmlns='tlen:iq:version'><name>%s</name><version>%s</version><os>%s</os></query></iq></message>", from, mver?mver:"", version?version:"", os?os:"" );
if (!item->versionRequested) {
item->versionRequested = TRUE;
- JabberSend(proto, "<message to='%s' type='iq'><iq type='get'><query xmlns='jabber:iq:version'/></iq></message>", from);
+ TlenSend(proto, "<message to='%s' type='iq'><iq type='get'><query xmlns='tlen:iq:version'/></iq></message>", 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, "<message to='%s'><x xmlns='jabber:x:event'><delivered/><id>%s</id></x></message>", from, (idStr != NULL)?idStr:"");
+ idStr = TlenXmlGetAttrValue(node, "id");
+ TlenSend(info->proto, "<message to='%s'><x xmlns='tlen:x:event'><delivered/><id>%s</id></x></message>", 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, "<iq/> Got roster push, query has %d children", queryNode->numChild);
+ TlenLog(info->proto, "<iq/> Got roster push, query has %d children", queryNode->numChild);
for (i=0; i<queryNode->numChild; 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: <iq type='result'><query ...
else if ( !strcmp( type, "result") && queryNode != NULL) {
if (xmlns != NULL ) {
- if ( !strcmp(xmlns, "jabber:iq:roster" )) {
- JabberIqResultRoster(info->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: <iq type='error'> ...
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: <iq type='1'>...
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");
}
|