diff options
author | George Hazan <george.hazan@gmail.com> | 2014-11-03 16:10:07 +0000 |
---|---|---|
committer | George Hazan <george.hazan@gmail.com> | 2014-11-03 16:10:07 +0000 |
commit | 415dcffc401ffdca1c0ccf94975c733b15d2e3c3 (patch) | |
tree | dca6756011ae055f2026393c6098052faef6ca48 /plugins/Sessions/Src/Utils.cpp | |
parent | 686b657701e50c3682045fdf4af9283e14087e04 (diff) |
massive code cleaning for Sessions
git-svn-id: http://svn.miranda-ng.org/main/trunk@10911 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/Sessions/Src/Utils.cpp')
-rw-r--r-- | plugins/Sessions/Src/Utils.cpp | 395 |
1 files changed, 165 insertions, 230 deletions
diff --git a/plugins/Sessions/Src/Utils.cpp b/plugins/Sessions/Src/Utils.cpp index fd84a86f8b..3a4271d942 100644 --- a/plugins/Sessions/Src/Utils.cpp +++ b/plugins/Sessions/Src/Utils.cpp @@ -21,46 +21,43 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. void AddSessionMark(MCONTACT hContact, int mode, char bit)
{
- DBVARIANT dbv;
- unsigned int i;
- char temp_1[1]={'\0'},temp_2[1]={'\0'};
- char szDst[256]={'\0'};
- char* pszBuffer=NULL;
- if (mode == 0) {
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
- temp_1[0]=dbv.pszVal[0];
- for (i=0; i < ses_limit; i++) {
- temp_2[0]=dbv.pszVal[i+1];
- dbv.pszVal[i+1]=temp_1[0];
- temp_1[0]=temp_2[0];
+ if (mode == 0) {
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
+ if (szValue) {
+ char temp_1 = szValue[0];
+ for (int i = 0; i < g_ses_limit; i++) {
+ char temp_2 = szValue[i + 1];
+ szValue[i + 1] = temp_1;
+ temp_1 = temp_2;
}
- for (i=ses_limit; i < 10; i++)
- dbv.pszVal[i]='0';
- dbv.pszVal[0]=bit;
- db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
- db_free(&dbv);
+ for (int i = g_ses_limit; i < 10; i++)
+ szValue[i] = '0';
+ szValue[0] = bit;
+ db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
}
- else if (bit == '1') db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
+ else if (bit == '1')
+ db_set_s(hContact, MODNAME, "LastSessionsMarks", "10000000000");
}
else if (mode == 1) {
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
- if (strlen(dbv.pszVal)<g_ses_count) {
- pszBuffer = (char*)mir_alloc(g_ses_count+1);
- ZeroMemory(pszBuffer,g_ses_count+1);
- strcpy(pszBuffer,dbv.pszVal);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
+ if (szValue) {
+ char *pszBuffer;
+ if (strlen(szValue) < g_ses_count) {
+ pszBuffer = (char*)mir_alloc(g_ses_count + 1);
+ ZeroMemory(pszBuffer, g_ses_count + 1);
+ strcpy(pszBuffer, szValue);
}
- else pszBuffer = mir_strdup(dbv.pszVal);
- db_free(&dbv);
-
- temp_1[0]=pszBuffer[0];
- for (i=0;i<g_ses_count;i++) {
- temp_2[0]=pszBuffer[i+1];
- pszBuffer[i+1]=temp_1[0];
- temp_1[0]=temp_2[0];
+ else pszBuffer = szValue.detouch();
+
+ char temp_1 = pszBuffer[0];
+ for (int i = 0; i < g_ses_count; i++) {
+ char temp_2 = pszBuffer[i+1];
+ pszBuffer[i+1] = temp_1;
+ temp_1 = temp_2;
}
- pszBuffer[0]=bit;
+ pszBuffer[0] = bit;
db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer);
-
+
mir_free(pszBuffer);
}
else if (bit == '1')
@@ -70,160 +67,112 @@ void AddSessionMark(MCONTACT hContact, int mode, char bit) }
}
-void RemoveSessionMark(MCONTACT hContact,int mode,int marknum)
+void RemoveSessionMark(MCONTACT hContact, int mode, int marknum)
{
- unsigned int i=1;
- char temp_1[1]={'\0'},temp_2[1]={'\0'};
- char szDst[256]={'\0'};
- DBVARIANT dbv;
-
if (mode == 0) {
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv) && dbv.pszVal) {
- for (i=marknum;i<ses_limit;i++)
- dbv.pszVal[i] = dbv.pszVal[i+1];
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
+ if (szValue) {
+ for (int i = marknum; i < g_ses_limit; i++)
+ szValue[i] = szValue[i+1];
- for (i=ses_limit;i<10;i++)
- dbv.pszVal[i] = '0';
+ for (int i = g_ses_limit; i < 10; i++)
+ szValue[i] = '0';
- db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
- db_free(&dbv);
+ db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
}
}
else if (mode == 1) {
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv) && dbv.pszVal) {
- for (i=marknum;i < ses_limit; i++)
- dbv.pszVal[i] = dbv.pszVal[i+1];
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
+ if (szValue) {
+ for (int i = marknum; i < g_ses_limit; i++)
+ szValue[i] = szValue[i+1];
- db_set_s(hContact, MODNAME, "UserSessionsMarks", dbv.pszVal);
- db_free(&dbv);
+ db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue);
}
}
}
-void SetSessionMark(MCONTACT hContact,int mode,char bit,unsigned int marknum)
+void SetSessionMark(MCONTACT hContact, int mode, char bit, unsigned int marknum)
{
- DBVARIANT dbv;
- char* pszBuffer=NULL;
-
- if (mode == 0) {
- if (!db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv)) {
- dbv.pszVal[marknum]=bit;
- db_set_s(hContact, MODNAME, "LastSessionsMarks", dbv.pszVal);
-
- db_free(&dbv);
+ if (mode == 0) {
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
+ if (szValue) {
+ szValue[marknum] = bit;
+ db_set_s(hContact, MODNAME, "LastSessionsMarks", szValue);
}
}
else if (mode == 1) {
- if (!db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv)) {
- pszBuffer = mir_strdup(dbv.pszVal);
- pszBuffer[marknum]=bit;
- db_set_s(hContact, MODNAME, "UserSessionsMarks", pszBuffer);
- mir_free(pszBuffer);
- db_free(&dbv);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsMarks"));
+ if (szValue) {
+ szValue[marknum] = bit;
+ db_set_s(hContact, MODNAME, "UserSessionsMarks", szValue);
}
}
}
-BOOL LoadContactsFromMask(MCONTACT hContact,int mode,int count)
-{
- DBVARIANT dbv;
- if (mode == 0) {
- if (db_get_s(hContact, MODNAME, "LastSessionsMarks", &dbv))
- return 0;
- }
- else if (mode == 1) {
- if (db_get_s(hContact, MODNAME, "UserSessionsMarks", &dbv))
- return 0;
- }
- else return 0;
+bool LoadContactsFromMask(MCONTACT hContact, int mode, int count)
+{
+ ptrA szValue;
+ if (mode == 0)
+ szValue = db_get_sa(hContact, MODNAME, "LastSessionsMarks");
+ else if (mode == 1)
+ szValue = db_get_sa(hContact, MODNAME, "UserSessionsMarks");
+
+ if (szValue == NULL)
+ return false;
- BOOL res = dbv.pszVal[count] == '1';
- db_free(&dbv);
- return res;
+ return szValue[count] == '1';
}
-void AddInSessionOrder(MCONTACT hContact,int mode,int ordernum,int writemode)
+void AddInSessionOrder(MCONTACT hContact, int mode, int ordernum, int writemode)
{
- int i;
- char temp_1[2]={'\0'},temp_2[2]={'\0'};
- char szDst[256]={'\0'};
- char* pszBuffer=NULL;
- char szFormNumBuf[255]={'\0'};
-
- if (ordernum<10)
- mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%u", 0, ordernum);
- else
- mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u", ordernum);
-
+ char szDst[256] = { '\0' };
+
+ char szFormNumBuf[100];
+ mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%02u", ordernum);
+
if (mode == 0) {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv)) {
- char* temp=NULL;
- char* temp2=NULL;
- int len= (int)strlen(dbv.pszVal);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsMarks"));
+ if (szValue) {
+ int len = (int)strlen(szValue);
if (!len)
len = 20;
- temp2 = (char*)mir_alloc(len-1);
- ZeroMemory(temp2,len-1);
- temp = (char*)mir_alloc(len+1);
- ZeroMemory(temp,len+1);
- if (ordernum < 10) {
- strncpy( temp2, dbv.pszVal, len-2 );
- temp2[len-2]='\0';
- mir_snprintf(temp, len+1, "%u%u%s", 0, ordernum, temp2);
- }
- else mir_snprintf(temp, len+1, "%u%s", ordernum, temp2);
+ char *temp2 = (char*)_alloca(len-1);
+ strncpy(temp2, szValue, len-2);
+ temp2[len-2]='\0';
+
+ char *temp = (char*)_alloca(len+1);
+ mir_snprintf(temp, len+1, "%02u%s", ordernum, temp2);
- for (i=(ses_limit*2);i<20;i++)
- temp[i]='0';
+ for (int i = (g_ses_limit * 2); i < 20; i++)
+ temp[i] = '0';
db_set_s(hContact, MODNAME, "LastSessionsOrder", temp);
- mir_free(temp);
- mir_free(temp2);
- db_free(&dbv);
}
else if (writemode == 1) {
- ZeroMemory(szFormNumBuf,SIZEOF(szFormNumBuf));
- if (ordernum<10)
- mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%u%s", 0, ordernum, "000000000000000000");
- else
- mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%u%s", ordernum, "000000000000000000");
-
+ mir_snprintf(szFormNumBuf, SIZEOF(szFormNumBuf), "%02u%s", ordernum, "000000000000000000");
db_set_s(hContact, MODNAME, "LastSessionsOrder", szFormNumBuf);
}
}
else if (mode == 1) {
- DBVARIANT dbv;
- int advlen=0;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
- char* temp=NULL;
- char* temp2=NULL;
- int len=0;
- if (strlen(dbv.pszVal)<(g_ses_count*2)) {
- pszBuffer = (char*)mir_alloc(g_ses_count*2+1);
- ZeroMemory(pszBuffer,g_ses_count*2+1);
- strcpy(pszBuffer,dbv.pszVal);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
+ if (szValue) {
+ char *pszBuffer;
+ if (strlen(szValue) < (g_ses_count * 2)) {
+ pszBuffer = (char*)mir_alloc(g_ses_count * 2 + 1);
+ ZeroMemory(pszBuffer, g_ses_count * 2 + 1);
+ strcpy(pszBuffer, szValue);
}
- else pszBuffer = mir_strdup(dbv.pszVal);
-
- if (!(advlen=len= (int)strlen(pszBuffer)))
- advlen=len=20;
- else
- advlen=len+2;
-
- temp = (char*)mir_alloc(advlen+1);
- ZeroMemory(temp,advlen+1);
-
- if (ordernum<10)
- mir_snprintf(temp, advlen+1, "%u%u%s", 0, ordernum, dbv.pszVal);
- else
- mir_snprintf(temp, advlen+1, "%u%s", ordernum, dbv.pszVal);
-
- db_free(&dbv);
+ else pszBuffer = mir_strdup(szValue);
+
+ int len = (int)strlen(pszBuffer);
+ len = (len == 0) ? 20 : len + 2;
+ char *temp = (char*)_alloca(len+1);
+ ZeroMemory(temp, len+1);
+ mir_snprintf(temp, len + 1, "%02u%s", ordernum, szValue);
db_set_s(hContact, MODNAME, "UserSessionsOrder", temp);
- mir_free(temp);
mir_free(pszBuffer);
}
else if (writemode == 1)
@@ -233,86 +182,74 @@ void AddInSessionOrder(MCONTACT hContact,int mode,int ordernum,int writemode) }
}
-int GetInSessionOrder(MCONTACT hContact,int mode,int count)
+int GetInSessionOrder(MCONTACT hContact, int mode, int count)
{
- int iOrder = 0;
- char szTemp[3]={'\0'};
- if (mode == 0) {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) {
- szTemp[0] = dbv.pszVal[count*2];
- szTemp[1] = dbv.pszVal[count*2+1];
- iOrder = atoi(szTemp);
- db_free(&dbv);
+ char szTemp[3];
+ if (mode == 0) {
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
+ if (szValue) {
+ strncpy_s(szTemp, &szValue[count*2], 2);
+ return atoi(szTemp);
}
}
else if (mode == 1) {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
- szTemp[0] = dbv.pszVal[count*2];
- szTemp[1] = dbv.pszVal[count*2+1];
- iOrder = atoi(szTemp);
- db_free(&dbv);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
+ if (szValue) {
+ strncpy_s(szTemp, &szValue[count*2], 2);
+ return atoi(szTemp);
}
}
- return iOrder;
+ return 0;
}
-void SetInSessionOrder(MCONTACT hContact,int mode,int count,unsigned int ordernum)
+void SetInSessionOrder(MCONTACT hContact, int mode, int count, unsigned int ordernum)
{
- int iOrder=0;
- char szTemp[3]={'\0'};
-
- if (ordernum < 10)
- mir_snprintf(szTemp, SIZEOF(szTemp), "%u%u", 0, ordernum);
- else
- mir_snprintf(szTemp, SIZEOF(szTemp), "%u", ordernum);
-
- if (mode == 0) {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "LastSessionsOrder", &dbv) && dbv.pszVal) {
- dbv.pszVal[count*2]=szTemp[0];
- dbv.pszVal[count*2+1]=szTemp[1];
- db_set_s(hContact, MODNAME, "LastSessionsOrder", dbv.pszVal);
- db_free(&dbv);
+ int iOrder = 0;
+
+ char szTemp[3];
+ mir_snprintf(szTemp, SIZEOF(szTemp), "%02u", ordernum);
+
+ if (mode == 0) {
+ ptrA szValue(db_get_sa(hContact, MODNAME, "LastSessionsOrder"));
+ if (szValue) {
+ szValue[count*2] = szTemp[0];
+ szValue[count*2 + 1] = szTemp[1];
+ db_set_s(hContact, MODNAME, "LastSessionsOrder", szValue);
}
}
else if (mode == 1) {
- DBVARIANT dbv;
- if (!db_get_s(hContact, MODNAME, "UserSessionsOrder", &dbv) && dbv.pszVal) {
- dbv.pszVal[count*2]=szTemp[0];
- dbv.pszVal[count*2+1]=szTemp[1];
- db_set_s(hContact, MODNAME, "UserSessionsOrder", dbv.pszVal);
- db_free(&dbv);
+ ptrA szValue(db_get_sa(hContact, MODNAME, "UserSessionsOrder"));
+ if (szValue) {
+ szValue[count*2] = szTemp[0];
+ szValue[count*2 + 1] = szTemp[1];
+ db_set_s(hContact, MODNAME, "UserSessionsOrder", szValue);
}
}
}
-BOOL ResaveSettings(char* szName,int iFirst,int iLimit,TCHAR* szBuffer)
+BOOL ResaveSettings(char* szName, int iFirst, int iLimit, TCHAR* szBuffer)
{
- BYTE marked,marked_t;
- char szNameBuf[256]={0};
+ BYTE marked, marked_t;
for (int i = iFirst; i < iLimit; i++) {
if (szBuffer == NULL)
break;
+ char szNameBuf[256];
mir_snprintf(szNameBuf, SIZEOF(szNameBuf), "%s_%u", szName, i);
- DBVARIANT dbv_temp;
- int res = db_get_ts(NULL, MODNAME, szNameBuf, &dbv_temp);
+ TCHAR *ptszTemp = db_get_tsa(NULL, MODNAME, szNameBuf);
db_set_ts(NULL, MODNAME, szNameBuf, szBuffer);
mir_free(szBuffer);
marked = IsMarkedUserDefSession(i);
- MarkUserDefSession(i,(BYTE)((i == iFirst)?IsMarkedUserDefSession(iFirst-1):marked_t));
+ MarkUserDefSession(i, (BYTE)((i == iFirst) ? IsMarkedUserDefSession(iFirst - 1) : marked_t));
marked_t = marked;
- if (res) // read failed
+ if (ptszTemp == NULL) // read failed
return 0;
-
- szBuffer = mir_tstrdup(dbv_temp.ptszVal);
- db_free(&dbv_temp);
+
+ szBuffer = ptszTemp;
}
mir_free(szBuffer);
@@ -332,12 +269,12 @@ int AddToCurSession(MCONTACT wparam, LPARAM lparam) return 0;
}
-int DelFromCurSession(MCONTACT wparam,LPARAM lparam)
+int DelFromCurSession(MCONTACT wparam, LPARAM lparam)
{
- for (int i=0; session_list[i] != 0; i++) {
+ for (int i = 0; session_list[i] != 0; i++) {
if (session_list[i] == wparam) {
- while(session_list[i+1]!=0) {
- session_list[i]=session_list[i+1];
+ while (session_list[i + 1] != 0) {
+ session_list[i] = session_list[i + 1];
i++;
}
session_list[i] = 0;
@@ -348,10 +285,9 @@ int DelFromCurSession(MCONTACT wparam,LPARAM lparam) int CheckForDuplicate(MCONTACT contact_list[], MCONTACT lparam)
{
- int i=0;
- MCONTACT s_list[255] = {0};
+ MCONTACT s_list[255] = { 0 };
memcpy(s_list, contact_list, SIZEOF(s_list));
- for (i=0;;i++) {
+ for (int i = 0;; i++) {
if (s_list[i] == lparam)
return i;
if (s_list[i] == 0)
@@ -360,30 +296,31 @@ int CheckForDuplicate(MCONTACT contact_list[], MCONTACT lparam) return 0;
}
-int LoadSessionToCombobox(HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iFirstNum)
+int LoadSessionToCombobox(HWND hdlg, BOOL mode, int iLimit, char* pszSetting, int iFirstNum)
{
int ses_count = iFirstNum, index;
- char szBuffer[256]={0};
+ char szBuffer[256] = { 0 };
if (session_list_recovered[0] && !iFirstNum && !mode) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)TranslateT("Session Before Last Crash"));
SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, index, 256);
}
- for(int i=0; i < iLimit; i++) {
+
+ for (int i = 0; i < iLimit; i++) {
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", pszSetting, i);
TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer);
if (pszBuffer) {
- if (!IsMarkedUserDefSession(i+iFirstNum)||mode == 1) {
+ if (!IsMarkedUserDefSession(i + iFirstNum) || mode == 1) {
index = SendDlgItemMessage(hdlg, IDC_LIST, CB_ADDSTRING, 0, (LPARAM)pszBuffer);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, i+iFirstNum);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, (WPARAM)index, i + iFirstNum);
}
else {
SendDlgItemMessage(hdlg, IDC_LIST, CB_INSERTSTRING, 0, (LPARAM)pszBuffer);
- SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, i+iFirstNum);
+ SendDlgItemMessage(hdlg, IDC_LIST, CB_SETITEMDATA, 0, i + iFirstNum);
}
mir_free(pszBuffer);
}
else {
- if (i == 0) ses_count=iLimit-iFirstNum;
+ if (i == 0) ses_count = iLimit - iFirstNum;
break;
}
}
@@ -391,17 +328,17 @@ int LoadSessionToCombobox(HWND hdlg,BOOL mode,int iLimit,char* pszSetting,int iF return ses_count;
}
-int FillFavoritesMenu (HMENU hMenu,int iLimit)
+int FillFavoritesMenu(HMENU hMenu, int iLimit)
{
- int iItems=0;
+ int iItems = 0;
- for(int i=0;i < iLimit; i++) {
+ for (int i = 0; i < iLimit; i++) {
if (IsMarkedUserDefSession(i)) {
char szBuffer[256];
mir_snprintf(szBuffer, SIZEOF(szBuffer), "%s_%u", "UserSessionDsc", i);
TCHAR *pszBuffer = db_get_tsa(NULL, MODNAME, szBuffer);
if (pszBuffer) {
- AppendMenu(hMenu,MF_STRING,i+1,pszBuffer);
+ AppendMenu(hMenu, MF_STRING, i + 1, pszBuffer);
iItems++;
mir_free(pszBuffer);
}
@@ -418,30 +355,28 @@ void OffsetWindow(HWND parent, HWND hwnd, int dx, int dy) pt.x = rc.left;
pt.y = rc.top;
ScreenToClient(parent, &pt);
- rc.left =pt.x ;
- rc.top =pt.y ;
+ rc.left = pt.x;
+ rc.top = pt.y;
OffsetRect(&rc, dx, dy);
- SetWindowPos(hwnd, NULL, rc.left, rc.top,0, 0, SWP_NOZORDER |SWP_NOSIZE);
+ SetWindowPos(hwnd, NULL, rc.left, rc.top, 0, 0, SWP_NOZORDER | SWP_NOSIZE);
}
int CheckContactVisibility(MCONTACT hContact)
-{
- if (db_get_b(hContact, "CList", "Hidden", 0))
- return 0;
- return 1;
+{
+ return !db_get_b(hContact, "CList", "Hidden", 0);
}
-void RenameUserDefSession(int ses_count,TCHAR* ptszNewName)
+void RenameUserDefSession(int ses_count, TCHAR* ptszNewName)
{
- char szSession[256]={0};
+ char szSession[256];
mir_snprintf(szSession, SIZEOF(szSession), "%s_%u", "UserSessionDsc", ses_count);
db_set_ts(NULL, MODNAME, szSession, ptszNewName);
}
-int MarkUserDefSession(int ses_count,BYTE bCheck)
+int MarkUserDefSession(int ses_count, BYTE bCheck)
{
- char szSessionName[256]={0};
+ char szSessionName[256];
mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "FavUserSession", ses_count);
db_set_b(NULL, MODNAME, szSessionName, bCheck);
return 0;
@@ -449,8 +384,8 @@ int MarkUserDefSession(int ses_count,BYTE bCheck) BYTE IsMarkedUserDefSession(int ses_count)
{
- char szSessionName[256]={0};
- mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u","FavUserSession", ses_count);
+ char szSessionName[256];
+ mir_snprintf(szSessionName, SIZEOF(szSessionName), "%s_%u", "FavUserSession", ses_count);
return db_get_b(NULL, MODNAME, szSessionName, 0);
}
@@ -466,11 +401,11 @@ void SavePosition(HWND hwnd, char *wndName) }
void LoadPosition(HWND hWnd, char *wndName)
-{
+{
char buffer[512];
mir_snprintf(buffer, SIZEOF(buffer), "%sPosX", wndName);
- int x = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2)-130);
+ int x = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CXSCREEN)) / 2) - 130);
mir_snprintf(buffer, SIZEOF(buffer), "%sPosY", wndName);
- int y = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CYSCREEN))/ 2)-80);
+ int y = db_get_dw(0, MODNAME, buffer, ((GetSystemMetrics(SM_CYSCREEN)) / 2) - 80);
SetWindowPos(hWnd, NULL, x, y, 0, 0, SWP_NOZORDER | SWP_NOOWNERZORDER | SWP_NOSIZE);
}
|