summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--init.cpp4
-rw-r--r--utilities.cpp47
-rw-r--r--utilities.h11
3 files changed, 56 insertions, 6 deletions
diff --git a/init.cpp b/init.cpp
index a61be5b..9c165de 100644
--- a/init.cpp
+++ b/init.cpp
@@ -24,7 +24,9 @@ static HANDLE hAccountsChanges;
PLUGINLINK *pluginLink;
static int OnModulesLoaded(WPARAM wParam,LPARAM lParam);
extern char *date();
-IJabberInterface *JabberInterface[10];
+//IJabberInterface *JabberInterface[10];
+JabberAccount Accounts;
+//TCHAR *JabberAccountName
int JabberAccountsCount = 0;
struct MM_INTERFACE mmi;
diff --git a/utilities.cpp b/utilities.cpp
index b2c28f0..10349f4 100644
--- a/utilities.cpp
+++ b/utilities.cpp
@@ -30,30 +30,67 @@ TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,c
return szRes;
}
-extern IJabberInterface *JabberInterface[10];
-extern int JabberAccountsCount;
+extern JabberAccount Accounts;
+
+int GetAccountsCount();
int GetJabberInterface(WPARAM, LPARAM) //get interface for all jabber accounts, options later
{
IJabberInterface *JIftmp[50]; //should it be dynamic ?
int count = 0;
PROTOACCOUNT **accounts;
+ JabberAccount *acc = &Accounts;
+ if(!acc)
+ acc = new(JabberAccount);
ProtoEnumAccounts(&count, &accounts);
- JabberAccountsCount = 0;
+ acc->AccountNumber = 0;
for(int i = 0; i < count; i++)
{
char *tmp = mir_u2a(accounts[i]->tszAccountName);
JIftmp[i] = getJabberApi(tmp);
+ if(!acc)
+ acc = new(JabberAccount);
if(JIftmp[i])
{
- JabberInterface[JabberAccountsCount] = JIftmp[i];
- JabberAccountsCount++;
+ acc->JabberInterface = JIftmp[i];
+ acc->AccountName = accounts[i]->tszAccountName;
+ acc->AccountNumber = i;
+ acc = acc->next;
+ acc = new(JabberAccount);
}
mir_free(tmp);
}
+ if(!GetAccountsCount())
+ return 1; //no jabber accounts found
return 0;
}
+BOOL JabberAccount::operator!()
+{
+ if(!this)
+ return TRUE;
+ return FALSE;
+}
+JabberAccount::JabberAccount()
+{
+ AccountName = _T("");
+ AccountNumber = 0;
+
+}
+
+JabberAccount::~JabberAccount()
+{
+ delete this;
+}
+int GetAccountsCount()
+{
+ int i;
+ JabberAccount *tmp = &Accounts;
+ for(i = 0; tmp; tmp=tmp->next, i++)
+ ;
+ return i;
+}
+
char *date()
{
diff --git a/utilities.h b/utilities.h
index 58374c8..0325f51 100644
--- a/utilities.h
+++ b/utilities.h
@@ -1,4 +1,15 @@
#ifndef UTILITIES_H
#define UTILITIES_H
TCHAR* __stdcall UniGetContactSettingUtf(HANDLE hContact, const char *szModule,const char* szSetting, TCHAR* szDef);
+class JabberAccount {
+public:
+ JabberAccount();
+ ~JabberAccount();
+ TCHAR *AccountName;
+ int AccountNumber;
+ IJabberInterface *JabberInterface;
+ class JabberAccount *next;
+ BOOL operator !();
+};
+
#endif