diff options
author | George Hazan <george.hazan@gmail.com> | 2012-07-02 20:37:03 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2012-07-02 20:37:03 +0000 |
commit | d961f42c7f709929258c2a5b33fbb47acc399522 (patch) | |
tree | 9582b5cc8adc3c74cb9abd0eda60fe910617f154 | |
parent | 5e81836e642adcbed92f9fdaa32afb80546e3aee (diff) |
- mir_cslock - class for locking critical sections;
- unneeded helpers removed;
- code cleaning in TTB
git-svn-id: http://svn.miranda-ng.org/main/trunk@727 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
-rw-r--r-- | include/m_system_cpp.h | 24 | ||||
-rw-r--r-- | plugins/TopToolBar/common.h | 29 | ||||
-rw-r--r-- | plugins/TopToolBar/toolbar.cpp | 156 | ||||
-rw-r--r-- | plugins/TopToolBar/ttbopt.cpp | 119 | ||||
-rw-r--r-- | plugins/helpers/gen_helpers.h | 24 | ||||
-rw-r--r-- | plugins/helpers/stshelpers.cpp | 303 | ||||
-rw-r--r-- | plugins/helpers/stshelpers.h | 35 | ||||
-rw-r--r-- | plugins/helpers/xmlhelpers.cpp | 418 | ||||
-rw-r--r-- | plugins/helpers/xmlhelpers.h | 17 |
9 files changed, 146 insertions, 979 deletions
diff --git a/include/m_system_cpp.h b/include/m_system_cpp.h index 76556160a6..0b79d4d552 100644 --- a/include/m_system_cpp.h +++ b/include/m_system_cpp.h @@ -33,9 +33,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #if defined(__cplusplus)
-#define NumericKeySortT -1
-#define HandleKeySortT -2
-#define PtrKeySortT -3
+///////////////////////////////////////////////////////////////////////////////
+// mir_ptr - automatic pointer for buffers, allocated using mir_alloc/mir_calloc
template<class T> class mir_ptr
{
@@ -51,6 +50,25 @@ public: __inline operator INT_PTR() const { return (INT_PTR)data; }
};
+///////////////////////////////////////////////////////////////////////////////
+// mir_cslock - automatic locker for the critical sections
+
+class mir_cslock
+{
+ CRITICAL_SECTION& cs;
+
+public:
+ __inline mir_cslock(CRITICAL_SECTION& _cs) : cs(_cs) { EnterCriticalSection(&cs); }
+ __inline ~mir_cslock() { LeaveCriticalSection(&cs); }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+// general lists' templates
+
+#define NumericKeySortT -1
+#define HandleKeySortT -2
+#define PtrKeySortT -3
+
template<class T> struct LIST
{
typedef int (*FTSortFunc)(const T* p1, const T* p2);
diff --git a/plugins/TopToolBar/common.h b/plugins/TopToolBar/common.h index 26620cf85f..ea577b4c74 100644 --- a/plugins/TopToolBar/common.h +++ b/plugins/TopToolBar/common.h @@ -92,7 +92,6 @@ TopButtonInt* CreateButton(TTBButton* but); int ttbOptionsChanged();
int ArrangeButtons();
-int RecreateWindows();
#define DEFBUTTWIDTH 20
#define DEFBUTTHEIGHT 16
@@ -102,20 +101,17 @@ int RecreateWindows(); extern LIST<TopButtonInt> Buttons;
extern bool StopArrange;
-extern HWND OptionshWnd, hwndTopToolBar;
+extern HWND hwndTopToolBar;
extern HANDLE hHookTTBModuleLoaded;
extern HINSTANCE hInst;
extern LIST<void> arHooks, arServices;
extern HBITMAP hBmpBackground, hBmpSeparator;
extern int BUTTWIDTH, BUTTHEIGHT, BUTTGAP;
+extern CRITICAL_SECTION csButtonsHook;
void AddToOptions(TopButtonInt* b);
void RemoveFromOptions(int id);
-//int OptionsPageRebuild();
-void lockbut();
-void ulockbut();
-
//append string
char *AS(char *str, const char *setting, char *addstr)
{
@@ -128,21 +124,18 @@ char *AS(char *str, const char *setting, char *addstr) #define TTB_LAUNCHSERVICE "TTB/LaunchSerice"
-int LoadInternalButtons( HWND );
-int UnLoadInternalButtons( void );
-
-int LoadToolbarModule( void );
-int UnloadToolbarModule( void );
+INT_PTR TTBAddButton(WPARAM, LPARAM);
+INT_PTR TTBRemoveButton(WPARAM, LPARAM);
-int SetAllBitmaps( void );
-int SaveAllLButs( void );
-int SaveAllButtonsOptions( void );
+int LoadInternalButtons( HWND );
+int UnLoadInternalButtons( void );
-void lockbut();
-void ulockbut();
+int LoadToolbarModule( void );
+int UnloadToolbarModule( void );
-INT_PTR TTBAddButton(WPARAM, LPARAM);
-INT_PTR TTBRemoveButton(WPARAM, LPARAM);
+void SetAllBitmaps( void );
+int SaveAllLButs( void );
+int SaveAllButtonsOptions( void );
void InsertSeparator( int i );
void DeleteSeparator(int i);
diff --git a/plugins/TopToolBar/toolbar.cpp b/plugins/TopToolBar/toolbar.cpp index 8a39e73a09..238558439b 100644 --- a/plugins/TopToolBar/toolbar.cpp +++ b/plugins/TopToolBar/toolbar.cpp @@ -16,7 +16,7 @@ COLORREF bkColour; HBITMAP hBmpBackground, hBmpSeparator;
int backgroundBmpUse;
-static CRITICAL_SECTION csButtonsHook;
+CRITICAL_SECTION csButtonsHook;
static int hFrameTopWindow = -1;
int sortfunc(const TopButtonInt* a, const TopButtonInt* b)
@@ -26,24 +26,11 @@ int sortfunc(const TopButtonInt* a, const TopButtonInt* b) LIST<TopButtonInt> Buttons(8, sortfunc);
-void lockbut()
+static void SetAllBitmaps()
{
- EnterCriticalSection(&csButtonsHook);
-}
-
-void ulockbut()
-{
- LeaveCriticalSection(&csButtonsHook);
-}
-
-int SetAllBitmaps()
-{
- lockbut();
+ mir_cslock lck(csButtonsHook);
for (int i = 0; i < Buttons.getCount(); i++)
Buttons[i]->SetBitmap();
-
- ulockbut();
- return 0;
}
static TopButtonInt* idtopos(int id, int* pPos=NULL)
@@ -74,8 +61,7 @@ void LoadAllSButs() {
//must be locked
int cnt = DBGetContactSettingByte(0, TTB_OPTDIR, "ServiceCnt", 0);
- if (cnt > 0)
- {
+ if (cnt > 0) {
for (int i = 1; i<=cnt; i++)
InsertSBut(i);
}
@@ -137,16 +123,15 @@ void LoadAllSeparators() int SaveAllButtonsOptions()
{
- lockbut();
int SeparatorCnt = 0;
int LaunchCnt = 0;
-
- for (int i = 0; i < Buttons.getCount(); i++)
- Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt);
-
+ {
+ mir_cslock lck(csButtonsHook);
+ for (int i = 0; i < Buttons.getCount(); i++)
+ Buttons[i]->SaveSettings(&SeparatorCnt, &LaunchCnt);
+ }
DBWriteContactSettingByte(0, TTB_OPTDIR, "SepCnt", SeparatorCnt);
DBWriteContactSettingByte(0, TTB_OPTDIR, "LaunchCnt", LaunchCnt);
- ulockbut();
return 0;
}
@@ -178,14 +163,12 @@ int ttbOptionsChanged() INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam)
{
- lockbut();
+ mir_cslock lck(csButtonsHook);
int idx;
TopButtonInt* b = idtopos(wParam, &idx);
- if (b == NULL) {
- ulockbut();
+ if (b == NULL)
return -1;
- }
RemoveFromOptions(b->id);
@@ -193,16 +176,17 @@ INT_PTR TTBRemoveButton(WPARAM wParam, LPARAM lParam) delete b;
ArrangeButtons();
- ulockbut();
return 0;
}
-bool nameexists(const char *name)
+static bool nameexists(const char *name)
{
- if (name != NULL)
- for (int i = 0; i < Buttons.getCount(); i++)
- if ( !lstrcmpA(Buttons[i]->name, name))
- return true;
+ if (name == NULL)
+ return false;
+
+ for (int i = 0; i < Buttons.getCount(); i++)
+ if ( !lstrcmpA(Buttons[i]->name, name))
+ return true;
return false;
}
@@ -224,19 +208,22 @@ HICON LoadIconFromLibrary(char *Name, HICON hIcon, HANDLE& phIcolib) return Skin_GetIconByHandle(phIcolib);
}
-int RecreateWindows()
+static void ReloadIcons()
{
- lockbut();
+ mir_cslock lck(csButtonsHook);
for (int i = 0; i < Buttons.getCount(); i++) {
- TopButtonInt *b = Buttons[i];
- if (b->hwnd) {
- DestroyWindow(b->hwnd);
- b->CreateWnd();
+ TopButtonInt* b = Buttons[i];
+
+ char buf[256];
+ if (b->hIconHandleUp) {
+ sprintf(buf, "%s_up", b->name);
+ b->hIconUp = LoadIconFromLibrary(buf, b->hIconUp, b->hIconHandleUp);
+ }
+ if (b->hIconHandleDn) {
+ sprintf(buf, "%s_dn", b->name);
+ b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
}
}
-
- ulockbut();
- return (0);
}
TopButtonInt* CreateButton(TTBButton* but)
@@ -306,27 +293,22 @@ INT_PTR TTBAddButton(WPARAM wParam, LPARAM lParam) if (hwndContactList == 0)
return -1;
- lockbut();
+ TopButtonInt* b;
+ {
+ mir_cslock lck(csButtonsHook);
- TTBButton *but = (TTBButton*)wParam;
- if ((but->cbSize != sizeof(TTBButton)) ||
- (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name))) {
- ulockbut();
- return -1;
- }
+ TTBButton *but = (TTBButton*)wParam;
+ if (but->cbSize != sizeof(TTBButton) || (!(but->dwFlags && TTBBF_ISLBUTTON) && nameexists(but->name)))
+ return -1;
- TopButtonInt* b = CreateButton(but);
-
- b->LoadSettings();
- Buttons.insert(b);
- b->CreateWnd();
+ b = CreateButton(but);
+ b->LoadSettings();
+ Buttons.insert(b);
+ b->CreateWnd();
+ }
- ulockbut();
ArrangeButtons();
-// OptionsPageRebuild();
-
AddToOptions(b);
-
return b->id;
}
@@ -335,7 +317,7 @@ int ArrangeButtons() if (StopArrange == TRUE)
return 0;
- lockbut();
+ mir_cslock lck(csButtonsHook);
RECT winrc;
GetClientRect(hwndTopToolBar, &winrc);
@@ -381,8 +363,6 @@ int ArrangeButtons() }
StopArrange = false;
-
- ulockbut();
return 1;
}
@@ -393,18 +373,15 @@ int ArrangeButtons() //lparam = state
INT_PTR TTBSetState(WPARAM wParam, LPARAM lParam)
{
- lockbut();
+ mir_cslock lck(csButtonsHook);
TopButtonInt* b = idtopos(wParam);
- if (b == NULL) {
- ulockbut();
+ if (b == NULL)
return -1;
- }
b->bPushed = (lParam&TTBST_PUSHED)?TRUE:FALSE;
b->bPushed = (lParam&TTBST_RELEASED)?FALSE:TRUE;
b->SetBitmap();
- ulockbut();
return 0;
}
@@ -413,15 +390,12 @@ INT_PTR TTBSetState(WPARAM wParam, LPARAM lParam) //return = state
INT_PTR TTBGetState(WPARAM wParam, LPARAM lParam)
{
- lockbut();
+ mir_cslock lck(csButtonsHook);
TopButtonInt* b = idtopos(wParam);
- if (b == NULL) {
- ulockbut();
+ if (b == NULL)
return -1;
- }
int retval = (b->bPushed == TRUE) ? TTBST_PUSHED : TTBST_RELEASED;
- ulockbut();
return retval;
}
@@ -429,12 +403,10 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam) {
INT_PTR retval;
- lockbut();
+ mir_cslock lck(csButtonsHook);
TopButtonInt* b = idtopos(wParam);
- if (b == NULL) {
- ulockbut();
+ if (b == NULL)
return -1;
- }
switch(LOWORD(wParam)) {
case TTBO_FLAGS:
@@ -479,7 +451,6 @@ INT_PTR TTBGetOptions(WPARAM wParam, LPARAM lParam) break;
}
- ulockbut();
return retval;
}
@@ -487,12 +458,10 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) {
int retval;
- lockbut();
+ mir_cslock lck(csButtonsHook);
TopButtonInt* b = idtopos(wParam);
- if (b == NULL) {
- ulockbut();
+ if (b == NULL)
return -1;
- }
switch(LOWORD(wParam)) {
case TTBO_FLAGS:
@@ -574,7 +543,6 @@ INT_PTR TTBSetOptions(WPARAM wParam, LPARAM lParam) break;
}
- ulockbut();
return retval;
}
@@ -717,12 +685,10 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara if ((HIWORD(wParam) == STN_CLICKED || HIWORD(wParam) == STN_DBLCLK)) {
int id = GetWindowLongPtr((HWND)lParam, GWLP_USERDATA);
if (id != 0) {
- lockbut();
+ mir_cslock lck(csButtonsHook);
TopButtonInt* b = idtopos(id);
- if (b == NULL || b->isSep()) {
- ulockbut();
+ if (b == NULL || b->isSep())
return 0;
- }
// flag inversion inside condition coz we uses Up -> Down for non-push buttons
// condition and inversion can be moved to main condition end
@@ -744,7 +710,6 @@ LRESULT CALLBACK TopToolBarProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lPara }
b->SetBitmap();
- ulockbut();
}
}
break;
@@ -796,22 +761,7 @@ static INT_PTR OnEventFire(WPARAM wParam, LPARAM lParam) int OnIconChange(WPARAM wParam, LPARAM lParam)
{
- lockbut();
- for (int i = 0; i < Buttons.getCount(); i++) {
- TopButtonInt* b = Buttons[i];
-
- char buf[256];
- if (b->hIconHandleUp) {
- sprintf(buf, "%s_up", b->name);
- b->hIconUp = LoadIconFromLibrary(buf, b->hIconUp, b->hIconHandleUp);
- }
- if (b->hIconHandleDn) {
- sprintf(buf, "%s_dn", b->name);
- b->hIconDn = LoadIconFromLibrary(buf, b->hIconDn, b->hIconHandleDn);
- }
- }
- ulockbut();
-
+ ReloadIcons();
SetAllBitmaps();
return 0;
}
diff --git a/plugins/TopToolBar/ttbopt.cpp b/plugins/TopToolBar/ttbopt.cpp index 63a342c459..6f9565896b 100644 --- a/plugins/TopToolBar/ttbopt.cpp +++ b/plugins/TopToolBar/ttbopt.cpp @@ -1,6 +1,42 @@ #include "common.h"
-HWND OptionshWnd = 0;
+static HWND OptionshWnd;
+
+void AddToOptions(TopButtonInt* b)
+{
+ if (OptionshWnd) {
+ HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE);
+ OrderData *dat = (struct OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
+ AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons);
+ }
+}
+
+void RemoveFromOptions(int id)
+{
+ if (OptionshWnd) {
+ HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE);
+ TVITEM tvi = { 0 };
+ tvi.hItem = TreeView_GetRoot(hTree);
+ tvi.mask = TVIF_PARAM | TVIF_HANDLE;
+
+ TopButtonInt* btn;
+ while(tvi.hItem != NULL) {
+ TreeView_GetItem(hTree, &tvi);
+ btn = (TopButtonInt*)tvi.lParam;
+ if (btn->id == id) {
+ // delete if was changed
+ if (btn->dwFlags & TTBBF_OPTIONAL)
+ delete btn;
+ TreeView_DeleteItem(hTree,tvi.hItem);
+ break;
+ }
+
+ tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
+ }
+ }
+}
+
+/////////////////////////////////////////////////////////////////////////////////////////
struct OrderData
{
@@ -9,7 +45,7 @@ struct OrderData HIMAGELIST himlButtonIcons;
};
-HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il)
+static HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il)
{
TVINSERTSTRUCT tvis = { 0 };
tvis.hInsertAfter = hItem;
@@ -46,7 +82,7 @@ HTREEITEM AddLine(HWND hTree,TopButtonInt *b, HTREEITEM hItem, HIMAGELIST il) return hti;
}
-int BuildTree(HWND hwndDlg)
+static int BuildTree(HWND hwndDlg)
{
HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
OrderData *dat = (struct OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
@@ -64,51 +100,7 @@ int BuildTree(HWND hwndDlg) return TRUE;
}
-void AddToOptions(TopButtonInt* b)
-{
- if (OptionshWnd) {
- HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE);
- OrderData *dat = (struct OrderData*)GetWindowLongPtr(hTree, GWLP_USERDATA);
- AddLine(hTree, b, TVI_LAST, dat->himlButtonIcons);
- }
-}
-
-void RemoveFromOptions(int id)
-{
- if (OptionshWnd) {
- HWND hTree = GetDlgItem(OptionshWnd, IDC_BUTTONORDERTREE);
- TVITEM tvi = { 0 };
- tvi.hItem = TreeView_GetRoot(hTree);
- tvi.mask = TVIF_PARAM | TVIF_HANDLE;
-
- TopButtonInt* btn;
- while(tvi.hItem != NULL) {
- TreeView_GetItem(hTree, &tvi);
- btn = (TopButtonInt*)tvi.lParam;
- if (btn->id == id) {
- // delete if was changed
- if (btn->dwFlags & TTBBF_OPTIONAL)
- delete btn;
- TreeView_DeleteItem(hTree,tvi.hItem);
- break;
- }
-
- tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
- }
- }
-}
-
-/*
-//call this when options opened and buttons added/removed
-int OptionsPageRebuild()
-{
- if (OptionshWnd)
- BuildTree(OptionshWnd);
-
- return 0;
-}
-*/
-void SaveTree(HWND hwndDlg)
+static void SaveTree(HWND hwndDlg)
{
HWND hTree = GetDlgItem(hwndDlg, IDC_BUTTONORDERTREE);
@@ -135,15 +127,14 @@ void SaveTree(HWND hwndDlg) tmpList.insert(btn);
tvi.hItem = TreeView_GetNextSibling(hTree, tvi.hItem);
}
+ {
+ mir_cslock lck(csButtonsHook);
+ for (int i=0; i < Buttons.getCount(); i++)
+ delete Buttons[i];
- lockbut();
- for (int i=0; i < Buttons.getCount(); i++)
- delete Buttons[i];
-
- Buttons = tmpList;
- tmpList.destroy();
-
- ulockbut();
+ Buttons = tmpList;
+ tmpList.destroy();
+ }
SaveAllButtonsOptions();
}
@@ -168,6 +159,18 @@ void CancelProcess(HWND hwndDlg) }
}
+static void RecreateWindows()
+{
+ mir_cslock lck(csButtonsHook);
+ for (int i = 0; i < Buttons.getCount(); i++) {
+ TopButtonInt *b = Buttons[i];
+ if (b->hwnd) {
+ DestroyWindow(b->hwnd);
+ b->CreateWnd();
+ }
+ }
+}
+
/////////////////////////////////////////////////////////////////////////////////////////
// Options window: main
@@ -400,7 +403,8 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR break;
TopButtonInt *btn = (TopButtonInt*)((LPNMTREEVIEW)lParam)->itemNew.lParam;
- lockbut();
+
+ mir_cslock lck(csButtonsHook);
if (btn->dwFlags & TTBBF_ISLBUTTON) {
bool enable = (btn->dwFlags & TTBBF_INTERNAL) !=0;
@@ -428,7 +432,6 @@ static INT_PTR CALLBACK ButOrderOpts(HWND hwndDlg, UINT msg, WPARAM wParam, LPAR SetDlgItemTextA(hwndDlg, IDC_ENAME, "");
SetDlgItemTextA(hwndDlg, IDC_EPATH, "");
}
- ulockbut();
}
}
break;
diff --git a/plugins/helpers/gen_helpers.h b/plugins/helpers/gen_helpers.h index 110ea9d30a..896b2638f4 100644 --- a/plugins/helpers/gen_helpers.h +++ b/plugins/helpers/gen_helpers.h @@ -94,28 +94,4 @@ static __inline int log_fatalA(const char* fmt, ...) { return 0; } static __inline int log_fatal(const TCHAR* fmt, ...) { return 0; }
#endif
-int Hlp_UnicodeCheck(char *szPluginName, BOOL bFore, const char *szModule);
-#define UnicodeCheck(x, y) Hlp_UnicodeCheck(x, y, MODULENAME)
-
-static __inline char *variables_parsedupA(char *szFormat, char *szExtraText, HANDLE hContact) {
-
- if (ServiceExists(MS_VARS_FORMATSTRING)) {
- FORMATINFO fi;
- char *szParsed, *szResult;
-
- ZeroMemory(&fi, sizeof(fi));
- fi.cbSize = sizeof(fi);
- fi.szFormat = szFormat;
- fi.szExtraText = szExtraText;
- fi.hContact = hContact;
- szParsed = (char *)CallService(MS_VARS_FORMATSTRING, (WPARAM)&fi, 0);
- if (szParsed) {
- szResult = _strdup(szParsed);
- CallService(MS_VARS_FREEMEMORY, (WPARAM)szParsed, 0);
- return szResult;
- }
- }
- return szFormat?_strdup(szFormat):szFormat;
-}
-
#endif
diff --git a/plugins/helpers/stshelpers.cpp b/plugins/helpers/stshelpers.cpp deleted file mode 100644 index abea62b3ba..0000000000 --- a/plugins/helpers/stshelpers.cpp +++ /dev/null @@ -1,303 +0,0 @@ -#include "commonheaders.h"
-#include "gen_helpers.h"
-#include <m_statusplugins.h>
-#include "stshelpers.h"
-
-static struct ProtoInfo {
- const char *szProto;
- UINT idEvent;
-};
-
-// note: accesses to pi are not synchronized... 'cause I'm a lazy SOB (and it's not necessary ATM)
-static struct ProtoInfo *pi = NULL;
-static int piCount = 0;
-static UINT g_idEvent = 0;
-static HWND hMessageWindow = NULL;
-static HANDLE hProtoAckHook = NULL;
-
-static VOID CALLBACK EnableProtoTimer(HWND hwnd, UINT message, UINT idEvent, DWORD dwTime) {
-
- int i;
-
- KillTimer(hwnd, idEvent);
- log_debugA("EnableProtoTimer");
- for (i=0;i<piCount;i++) {
- if (pi[i].idEvent == idEvent) {
- log_debugA("cleaning timer %d (%d) for %s (%x) (%d) (%d events left)", i, idEvent, pi[i].szProto, pi[i].szProto, pi[i].idEvent, piCount);
- if (i < piCount-1) {
- log_debugA("(1) pi[%d] (%s %x) pi[%d] (%s %x )", i, pi[i].szProto, pi[i].szProto, i+1, pi[i+1].szProto, pi[i+1].szProto);
- MoveMemory(&pi[i], &pi[i+1], (piCount-i-1)*sizeof(struct ProtoInfo));
- log_debugA("(2) pi[%d] (%s %x) pi[%d] (%s %x )", i, pi[i].szProto, pi[i].szProto, i+1, pi[i+1].szProto, pi[i+1].szProto);
- }
- if (piCount > 1) {
- pi = realloc(pi, (piCount-1)*sizeof(struct ProtoInfo));
- }
- else {
- free(pi);
- pi = NULL;
- log_debugA("(3) pi freed");
- }
- piCount -= 1;
- }
- }
-}
-
-static int ProtoAck(WPARAM wParam, LPARAM lParam) {
-
- int status;
- ACKDATA *ack;
-
- ack = (ACKDATA*)lParam;
- if (ack->type != ACKTYPE_STATUS) return 0;
- if (ack->result != ACKRESULT_SUCCESS) return 0;
- log_debugA("StatusHandling ProtoAck");
- status = CallProtoService(ack->szModule, PS_GETSTATUS, 0, 0);
- log_debugA("StatusHandling ProtoAck status=%d", status);
- if ( (status < MIN_STATUS) || (status > MAX_STATUS) ) {
- return 0;
- }
- pi = realloc(pi, (piCount+1)*sizeof(struct ProtoInfo));
- g_idEvent += 1;
- pi[piCount].idEvent = g_idEvent;
- pi[piCount].szProto = ack->szModule;
- piCount += 1;
- log_debugA("added timer %d for pi[%d] %s (%x)", pi[piCount-1].idEvent, piCount-1, ack->szModule, ack->szModule);
- SetTimer(hMessageWindow, g_idEvent, CONNECTIONTIMEOUT, EnableProtoTimer);
-
- return 0;
-}
-
-int InitProtoStatusChangedHandling() {
-
- if (hMessageWindow == NULL) {
- int i, count;
- PROTOCOLDESCRIPTOR **protos;
-
- CallService(MS_PROTO_ENUMPROTOCOLS, (WPARAM)&count, (LPARAM)&protos);
- for(i=0;i<count;i++) {
- if (protos[i]->type!=PROTOTYPE_PROTOCOL || CallProtoService(protos[i]->szName,PS_GETCAPS,PFLAGNUM_2,0)==0) continue;
- //pi = realloc(pi, (piCount + 1)*sizeof(struct ProtoInfo));
- //ZeroMemory(&pi[piCount], sizeof(struct ProtoInfo));
- //pi[piCount].szProto = protos[i].szName;
- log_debugA("InitProtoStatusChangedHandling: %s added", protos[i]->szName);
- }
- hMessageWindow = CreateWindowExA(0, "STATIC", NULL, 0, 0, 0, 0, 0, NULL, NULL, NULL, NULL);
- hProtoAckHook = HookEvent(ME_PROTO_ACK, ProtoAck);
-
- return 0;
- }
-
- return 1;
-}
-
-int ProtoChangedStatus(char *szProto) {
-
- int i;
-
- log_debugA("ProtoChangedStatus %s", szProto);
- if (szProto != NULL) {
- for (i=0;i<piCount;i++) {
- if ( (pi[i].szProto != NULL) && (szProto != NULL) && (!strcmp(pi[i].szProto, szProto)) ) {
- log_debugA("%s just changed status", szProto);
-
- return TRUE;
- }
- }
- }
-
- return FALSE;
-}
-
-int Flag2Status(unsigned long flag) {
-
- switch(flag) {
- case PF2_ONLINE: return ID_STATUS_ONLINE;
- case PF2_OFFLINE:
- case 0: return ID_STATUS_OFFLINE;
- case PF2_INVISIBLE: return ID_STATUS_INVISIBLE;
- case PF2_OUTTOLUNCH: return ID_STATUS_OUTTOLUNCH;
- case PF2_ONTHEPHONE: return ID_STATUS_ONTHEPHONE;
- case PF2_SHORTAWAY: return ID_STATUS_AWAY;
- case PF2_LONGAWAY: return ID_STATUS_NA;
- case PF2_LIGHTDND: return ID_STATUS_OCCUPIED;
- case PF2_HEAVYDND: return ID_STATUS_DND;
- case PF2_FREECHAT: return ID_STATUS_FREECHAT;
- case PF2_IDLE: return ID_STATUS_IDLE;
- case PF2_CURRENT: return ID_STATUS_CURRENT;
- case PF2_FROMTRIGGER: return ID_STATUS_FROMTRIGGER;
- }
- return 0;
-}
-
-unsigned long Status2Flag(int status) {
-
- switch(status) {
- case ID_STATUS_ONLINE: return PF2_ONLINE;
- case ID_STATUS_OFFLINE: return PF2_OFFLINE;
- case ID_STATUS_INVISIBLE: return PF2_INVISIBLE;
- case ID_STATUS_OUTTOLUNCH: return PF2_OUTTOLUNCH;
- case ID_STATUS_ONTHEPHONE: return PF2_ONTHEPHONE;
- case ID_STATUS_AWAY: return PF2_SHORTAWAY;
- case ID_STATUS_NA: return PF2_LONGAWAY;
- case ID_STATUS_OCCUPIED: return PF2_LIGHTDND;
- case ID_STATUS_DND: return PF2_HEAVYDND;
- case ID_STATUS_FREECHAT: return PF2_FREECHAT;
- case ID_STATUS_IDLE: return PF2_IDLE;
- case ID_STATUS_CURRENT: return PF2_CURRENT;
- case ID_STATUS_FROMTRIGGER: return PF2_FROMTRIGGER;
- }
- return 0;
-}
-
-static int GetActualStatus(SETSTATUSINFO *ssi) {
-
- if ( (ssi->status == ID_STATUS_CURRENT) || (ssi->flags&SSIF_DONTSETSTATUS) ) {
- return CallProtoService(ssi->szProto, PS_GETSTATUS, 0, 0);
- }
-
- return ssi->status;
-}
-
-static int EqualsGlobalStatus(SETSTATUSINFO *ssi, int count) {
-
- PROTOCOLDESCRIPTOR **protos;
- int i, j, protoCount, pstatus, gstatus;
-
- if ( (count == 1) && (ssi[0].flags&SSIF_USEAWAYSYS) && (ssi[0].szProto == NULL) ) {
- return ssi[0].status;
- }
- pstatus = gstatus = 0;
- CallService(MS_PROTO_ENUMPROTOCOLS,(WPARAM)&protoCount,(LPARAM)&protos);
- for (i=0;i<protoCount;i++) {
- if ( (protos[i]->type != PROTOTYPE_PROTOCOL) || (CallProtoService(ssi[i].szProto, PS_GETCAPS, PFLAGNUM_2, 0) == 0)) continue;
- pstatus = 0;
- for (j=0;j<count;j++) {
- if (!strcmp(protos[i]->szName, ssi[j].szProto)) {
- if (ssi[j].flags&SSIF_DONTSETSTATUS) {
- // not all proto's will be set
- return 0;
- }
- if (!(ssi[j].flags&SSIF_USEAWAYSYS)) {
- // not all proto's handled by awaysys
- return 0;
- }
- pstatus = GetActualStatus(&ssi[j]);
- }
- else {
- // not all proto's will be set
- return 0;
- }
- }
- if (pstatus == 0) {
- pstatus = CallProtoService(protos[i]->szName, PS_GETSTATUS, 0, 0);
- }
- if (gstatus == 0) {
- gstatus = pstatus;
- }
- if (pstatus != gstatus) {
- return 0;
- }
- }
-
- return gstatus;
-}
-
-// helper, from core
-static char *GetDefaultMessage(int status)
-{
- switch(status) {
- case ID_STATUS_AWAY: return Translate("I've been away since %time%.");
- case ID_STATUS_NA: return Translate("Give it up, I'm not in!");
- case ID_STATUS_OCCUPIED: return Translate("Not right now.");
- case ID_STATUS_DND: return Translate("Give a guy some peace, would ya?");
- case ID_STATUS_FREECHAT: return Translate("I'm a chatbot!");
- case ID_STATUS_ONLINE: return Translate("Yep, I'm here.");
- case ID_STATUS_OFFLINE: return Translate("Nope, not here.");
- case ID_STATUS_INVISIBLE: return Translate("I'm hiding from the mafia.");
- case ID_STATUS_ONTHEPHONE: return Translate("That'll be the phone.");
- case ID_STATUS_OUTTOLUNCH: return Translate("Mmm...food.");
- case ID_STATUS_IDLE: return Translate("idleeeeeeee");
- }
- return NULL;
-}
-
-static char *GetDefaultStatusMessage(int newstatus) {
-
- char *sMsg, *tMsg;
-
- sMsg = NULL;
- if (ServiceExists(MS_AWAYMSG_GETSTATUSMSG)) {
- tMsg = (char*)CallService(MS_AWAYMSG_GETSTATUSMSG, (WPARAM)newstatus, 0);
- if (tMsg != NULL) {
- sMsg = _strdup(tMsg);
- mir_free(tMsg);
- }
- }
- else {
- tMsg = GetDefaultMessage(newstatus); /* awaysys doesn't define the service above */
- if (tMsg != NULL) {
- sMsg = _strdup(tMsg);
- }
- }
-
- return sMsg;
-}
-
-int Hlp_SetStatus(SETSTATUSINFO *ssi, int count) {
-
- int i, status;
- char *szMsg;
-
- status = EqualsGlobalStatus(ssi, count);
- if (status != 0) {
- log_debugA("Hlp_SetStatus: Setting global status");
- CallService(MS_CLIST_SETSTATUSMODE, (WPARAM)status, 0);
- return 0;
- }
- for (i=0;i<count;i++) {
- if (!CallService(MS_PROTO_ISPROTOCOLLOADED, 0, (LPARAM)ssi[i].szProto)) {
- log_debugA("Hlp_SetStatus: %s not loaded", ssi[i].szProto);
- continue;
- }
- status = GetActualStatus(&ssi[i]);
- if (!(ssi[i].flags&SSIF_DONTSETSTATUS)) {
- if (ServiceExists(MS_KS_ANNOUNCESTATUSCHANGE)) {
- log_debugA("Hlp_SetStatus: Announcing status change to KeepStatus");
- announce_status_change(ssi[i].szProto, status, ssi[i].flags&SSIF_DONTSETMESSAGE?NULL:ssi[i].szMsg);
- }
- log_debugA("Hlp_SetStatus: Setting status %d for %s", status, ssi[i].szProto);
- CallProtoService(ssi[i].szProto, PS_SETSTATUS, (WPARAM)status, 0);
- }
- if (!(ssi[i].flags&SSIF_DONTSETMESSAGE)) {
- if (ssi[i].flags&SSIF_USEAWAYSYS) {
- szMsg = GetDefaultStatusMessage(status);
- }
- else {
- if (ssi[i].szMsg != NULL) {
- szMsg = _strdup(ssi[i].szMsg);
- }
- else {
- szMsg = NULL;
- }
- }
- log_debugA("Hlp_SetStatus: Setting statusmessage for %d for %s", status, ssi[i].szProto);
- CallProtoService(ssi[i].szProto, PS_SETAWAYMSG, (WPARAM)status, (LPARAM)szMsg);
- if (szMsg != NULL) {
- free(szMsg);
- }
- }
- }
-
- return 0;
-}
-
-void Hlp_FreeStatusInfo(SETSTATUSINFO *ssi, int count) {
-
- int i;
-
- for (i=0;i<count;i++) {
- if (ssi[i].szMsg != NULL) {
- free(ssi[i].szMsg);
- }
- }
-}
\ No newline at end of file diff --git a/plugins/helpers/stshelpers.h b/plugins/helpers/stshelpers.h deleted file mode 100644 index f0fbca8fae..0000000000 --- a/plugins/helpers/stshelpers.h +++ /dev/null @@ -1,35 +0,0 @@ -#ifndef __STSHELPERS__
-#define __STSHELPERS__
-#define PF2_FROMTRIGGER 0x00002000
-#define PF2_CURRENT 0x00001000
-#define PF2_OFFLINE 0x00000800
-#define ID_STATUS_CURRENT 41000
-#define ID_STATUS_FROMTRIGGER 41001
-
-#define MIN_STATUS ID_STATUS_OFFLINE
-#define MAX_STATUS ID_STATUS_OUTTOLUNCH
-
-#define SSIF_DONTSETSTATUS 0x01
-#define SSIF_DONTSETMESSAGE 0x02
-#define SSIF_USEAWAYSYS 0x04
-
-typedef struct {
- char *szProto;
- int flags;
- int status;
- char *szMsg;
-} SETSTATUSINFO;
-
-// find out whether a proto just changed status
-#define CONNECTIONTIMEOUT 6000 // same value as NewStatusNotify
-// call this...
-int InitProtoStatusChangedHandling();
-// ...if you want to use this
-int ProtoChangedStatus(char *szProto);
-
-int Flag2Status(unsigned long flag); // only if flag is only one status
-unsigned long Status2Flag(int status);
-int Hlp_SetStatus(SETSTATUSINFO *ssi, int count);
-void Hlp_FreeStatusInfo(SETSTATUSINFO *ssi, int count);
-
-#endif
diff --git a/plugins/helpers/xmlhelpers.cpp b/plugins/helpers/xmlhelpers.cpp deleted file mode 100644 index b6d3fa70c8..0000000000 --- a/plugins/helpers/xmlhelpers.cpp +++ /dev/null @@ -1,418 +0,0 @@ -#include "commonheaders.h"
-#include "gen_helpers.h"
-
-char *XMLEncodeString(TCHAR *tszSrc) {
-
- int cur, len;
- TCHAR *tszEsc, *tszRep;
- char *szRes;
-
- if (tszSrc == NULL) {
- return NULL;
- }
- tszEsc = _tcsdup(tszSrc);
- cur = len = 0;
- while (tszEsc[cur] != _T('\0')) {
- tszRep = NULL;
- switch (tszEsc[cur]) {
- case _T('<'):
- len = 1;
- tszRep = _T("<");
- break;
- case _T('>'):
- len = 1;
- tszRep = _T(">");
- break;
- case _T('&'):
- len = 1;
- tszRep = _T("&");
- break;
- case _T('\''):
- len = 1;
- tszRep = _T("'");
- break;
- case _T('"'):
- len = 1;
- tszRep = _T(""");
- break;
- case _T('\r'):
- if (tszEsc[cur+1] == _T('\n')) {
- len = 2;
- tszRep = _T("
");
- }
- break;
- case _T('\n'):
- len = 1;
- tszRep = _T("
");
- break;
- }
- // tszRep > len !!!
- if (tszRep != NULL) {
- tszEsc = realloc(tszEsc, (_tcslen(tszEsc) + _tcslen(tszRep) - len + 1)*sizeof(TCHAR));
- MoveMemory(&tszEsc[cur+_tcslen(tszRep) - len], &tszEsc[cur], _tcslen(&tszEsc[cur]) + 1);
- CopyMemory(&tszEsc[cur], tszRep, _tcslen(tszRep)*sizeof(TCHAR));
- cur += _tcslen(tszRep);
- }
- else {
- cur++;
- }
- }
-#ifdef UNICODE
- szRes = Utf8EncodeUcs2(tszEsc);
-#else
- szRes = Utf8Encode(tszEsc);
-#endif
- free(tszEsc);
-
- return szRes;
-}
-
-char *XMLEncodeStringA(char *szSrc) {
-
- int cur, len;
- char *szEsc, *szRep;
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
- cur = len = 0;
- while (szEsc[cur] != '\0') {
- szRep = NULL;
- switch (szEsc[cur]) {
- case '<':
- len = 1;
- szRep = "<";
- break;
- case '>':
- len = 1;
- szRep = ">";
- break;
- case '&':
- len = 1;
- szRep = "&";
- break;
- case '\'':
- len = 1;
- szRep = "'";
- break;
- case '"':
- len = 1;
- szRep = """;
- break;
- case '\r':
- if (szEsc[cur+1] == '\n') {
- len = 2;
- szRep = "
";
- }
- break;
- case '\n':
- len = 1;
- szRep = "
";
- break;
- }
- if (szRep != NULL) {
- szEsc = realloc(szEsc, (strlen(szEsc) + strlen(szRep) - len + 1));
- MoveMemory(&szEsc[cur+strlen(szRep) - len], &szEsc[cur], strlen(&szEsc[cur]) + 1);
- CopyMemory(&szEsc[cur], szRep, strlen(szRep));
- cur+=strlen(szRep);
- }
- else {
- cur++;
- }
- }
-
- return szEsc;
-}
-
-TCHAR *DecodeXMLString(char *szSrc) {
-
- int cur;
- TCHAR *tszEsc, *tszRep, *tszTrans;
- char *szEsc;
-#ifdef UNICODE
- wchar_t *wszEsc;
-#endif
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
-#ifdef UNICODE
- Utf8Decode(szEsc, &wszEsc);
- tszEsc = wszEsc;
- free(szEsc);
-#else
- Utf8Decode(szEsc, NULL);
- tszEsc = szEsc;
-#endif
- cur= 0;
- while (tszEsc[cur] != _T('\0')) {
- tszRep = NULL;
- if (!_tcsncmp(&tszEsc[cur], _T("<"), 4)) {
- tszRep = _T("<");
- tszTrans = _T("<");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T(">"), 4)) {
- tszRep = _T(">");
- tszTrans = _T(">");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("&"), 5)) {
- tszRep = _T("&");
- tszTrans = _T("&");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("'"), 6)) {
- tszRep = _T("'");
- tszTrans = _T("\'");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("""), 6)) {
- tszRep = _T(""");
- tszTrans = _T("&");
- }
- else if (!_tcsncmp(&tszEsc[cur], _T("
"), 5)) {
- tszRep = _T("
");
- tszTrans = _T("\r\n");
- }
- if (tszRep != NULL) {
- tszEsc = realloc(tszEsc, (_tcslen(tszEsc) - _tcslen(tszRep) + _tcslen(tszTrans) + 1)*sizeof(TCHAR));
- MoveMemory(&tszEsc[cur+_tcslen(tszTrans)], &tszEsc[cur+_tcslen(tszRep)], _tcslen(&tszEsc[cur+_tcslen(tszRep)]) + 1);
- CopyMemory(&tszEsc[cur], tszTrans, _tcslen(tszTrans)*sizeof(TCHAR));
- cur += _tcslen(tszTrans);
- }
- else {
- cur++;
- }
- }
-
- return tszEsc;
-}
-
-char *DecodeXMLStringA(char *szSrc, BOOL bUtfDecode) {
-
- int cur;
- char *szEsc, *szRep, *szTrans;
-
- if (szSrc == NULL) {
- return NULL;
- }
- szEsc = _strdup(szSrc);
- if (bUtfDecode) {
- Utf8Decode(szEsc, NULL);
- }
- cur= 0;
- while (szEsc[cur] != '\0') {
- szRep = NULL;
- if (!strncmp(&szEsc[cur], "<", 4)) {
- szRep = "<";
- szTrans = "<";
- }
- else if (!strncmp(&szEsc[cur], ">", 4)) {
- szRep = ">";
- szTrans = ">";
- }
- else if (!strncmp(&szEsc[cur], "&", 5)) {
- szRep = "&";
- szTrans = "&";
- }
- else if (!strncmp(&szEsc[cur], "'", 6)) {
- szRep = "'";
- szTrans = "'";
- }
- else if (!strncmp(&szEsc[cur], """, 6)) {
- szRep = """;
- szTrans = "&";
- }
- else if (!strncmp(&szEsc[cur], "
", 5)) {
- szRep = "
";
- szTrans = "\r\n";
- }
- if (szRep != NULL) {
- szEsc = realloc(szEsc, (strlen(szEsc) - strlen(szRep) + strlen(szTrans) + 1));
- MoveMemory(&szEsc[cur+strlen(szTrans)], &szEsc[cur+strlen(szRep)], strlen(&szEsc[cur+strlen(szRep)]) + 1);
- CopyMemory(&szEsc[cur], szTrans, strlen(szTrans));
- cur += strlen(szTrans);
- }
- else {
- cur++;
- }
- }
-
- return szEsc;
-}
-
-void AppendXMLOpeningTag(char **szBuf, char *szTag, int *depth) {
-
- char *cur;
-
- *depth += 1;
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 4);
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- sprintf(*szBuf+strlen(*szBuf), "<%s>", szTag);
-}
-
-void AppendXMLClosingTag(char **szBuf, char *szTag, int *depth) {
-
- char *cur;
-
- *depth -= 1;
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 5);
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- sprintf(*szBuf+strlen(*szBuf), "</%s>", szTag);
-}
-
-void AppendXMLTag(char **szBuf, char *szTag, char *szAtts, int *depth) {
-
- char *cur;
-
- *depth += 1;
- if (szAtts != NULL) {
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + strlen(szAtts) + *depth + 6);
- }
- else {
- *szBuf = realloc(*szBuf, strlen(*szBuf) + strlen(szTag) + *depth + 5);
- }
- cur = *szBuf+strlen(*szBuf);
- *cur = '\n';
- if (*depth > 0) {
- memset(cur+1, ' ', *depth);
- }
- *(cur+1+*depth) = '\0';
- if (szAtts != NULL) {
- sprintf(*szBuf+strlen(*szBuf), "<%s %s/>", szTag, szAtts);
- }
- else {
- sprintf(*szBuf+strlen(*szBuf), "<%s/>", szTag);
- }
- *depth -= 1;
-}
-
-char *GetSettingType(BYTE type) {
-
- switch (type) {
- case DBVT_BYTE:
- return "BYTE";
- case DBVT_WORD:
- return "WORD";
- case DBVT_DWORD:
- return "DWORD";
- case DBVT_ASCIIZ:
- return "ASCIIZ";
- case DBVT_BLOB:
- return "BLOB";
- case DBVT_UTF8:
- return "UTF8";
- case DBVT_WCHAR:
- return "WCHAR";
- }
- return "UNKNOWN";
-}
-
-void AppendXMLTagTString(char **szBuf, char *szTag, TCHAR *tszVal, int *depth) {
-
- char *szVal, *szAtts, *szType;
-
- szVal = XMLEncodeString(tszVal);
-#ifdef UNICODE
- szType = GetSettingType(DBVT_WCHAR);
-#else
- szType = GetSettingType(DBVT_ASCIIZ);
-#endif
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szVal);
-}
-
-void AppendXMLTagString(char **szBuf, char *szTag, char *szVal, int *depth) {
-
- char *szEnc, *szAtts, *szType;
-
- szEnc = XMLEncodeStringA(szVal);
- szType = GetSettingType(DBVT_ASCIIZ);
- szAtts = malloc(strlen(szEnc) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szEnc);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szEnc);
-}
-
-void AppendXMLTagUtfString(char **szBuf, char *szTag, char *szVal, int *depth) {
-
- char *szEnc, *szAtts, *szType;
-
- szEnc = XMLEncodeStringA(szVal);
- szType = GetSettingType(DBVT_UTF8);
- szAtts = malloc(strlen(szEnc) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szEnc);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
- free(szEnc);
-}
-
-void AppendXMLTagByte(char **szBuf, char *szTag, BYTE bVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", bVal);
- szType = GetSettingType(DBVT_BYTE);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagWord(char **szBuf, char *szTag, WORD wVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", wVal);
- szType = GetSettingType(DBVT_WORD);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagDword(char **szBuf, char *szTag, DWORD dVal, int *depth) {
-
- char szVal[64], *szAtts, *szType;
-
- mir_snprintf(szVal, sizeof(szVal), "0x%x", dVal);
- szType = GetSettingType(DBVT_DWORD);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
-
-void AppendXMLTagBlob(char **szBuf, char *szTag, BYTE *pBlob, int cbBlob, int *depth) {
-
- int maxLen;
- char *szType, *szVal, *szAtts;
- NETLIBBASE64 nlb;
-
- maxLen = Netlib_GetBase64EncodedBufferSize(cbBlob);
- szVal = malloc(maxLen + 1);
- ZeroMemory(&nlb, sizeof(NETLIBBASE64));
- nlb.cbDecoded = cbBlob;
- nlb.pbDecoded = pBlob;
- nlb.cchEncoded = maxLen;
- nlb.pszEncoded = szVal;
- CallService(MS_NETLIB_BASE64ENCODE, 0, (LPARAM)&nlb);
- szType = GetSettingType(DBVT_BLOB);
- szAtts = malloc(strlen(szVal) + strlen(szType) + 17);
- sprintf(szAtts, "type=\"%s\" value=\"%s\"", szType, szVal);
- AppendXMLTag(szBuf, szTag, szAtts, depth);
- free(szAtts);
-}
diff --git a/plugins/helpers/xmlhelpers.h b/plugins/helpers/xmlhelpers.h deleted file mode 100644 index dd0cc822a7..0000000000 --- a/plugins/helpers/xmlhelpers.h +++ /dev/null @@ -1,17 +0,0 @@ -void AppendXMLOpeningTag(char **szBuf, char *szTag, int *depth);
-void AppendXMLClosingTag(char **szBuf, char *szTag, int *depth);
-void AppendXMLTag(char **szBuf, char *szTag, char *szAtts, int *depth);
-
-char *GetSettingType(BYTE type);
-void AppendXMLTagTString(char **szBuf, char *szTag, TCHAR *tszVal, int *depth);
-void AppendXMLTagString(char **szBuf, char *szTag, char *szVal, int *depth);
-void AppendXMLTagUtfString(char **szBuf, char *szTag, char *szVal, int *depth);
-void AppendXMLTagByte(char **szBuf, char *szTag, BYTE bVal, int *depth);
-void AppendXMLTagWord(char **szBuf, char *szTag, WORD wVal, int *depth);
-void AppendXMLTagDword(char **szBuf, char *szTag, DWORD dVal, int *depth);
-void AppendXMLTagBlob(char **szBuf, char *szTag, BYTE *pBlob, int cbBlob, int *depth);
-
-char *XMLEncodeString(TCHAR *szSrc);
-char *XMLEncodeStringA(char *tszSrc);
-TCHAR *DecodeXMLString(char *szSrc);
-char *DecodeXMLStringA(char *szSrc, BOOL bUtfDecode);
|