diff options
Diffstat (limited to 'plugins/UserInfoEx')
-rw-r--r-- | plugins/UserInfoEx/src/ctrl_contact.cpp | 11 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp | 2 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_db.cpp | 11 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/mir_db.h | 5 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/svc_avatar.cpp | 86 | ||||
-rw-r--r-- | plugins/UserInfoEx/src/svc_reminder.cpp | 60 |
6 files changed, 54 insertions, 121 deletions
diff --git a/plugins/UserInfoEx/src/ctrl_contact.cpp b/plugins/UserInfoEx/src/ctrl_contact.cpp index 14825a6820..2bdedb3ae5 100644 --- a/plugins/UserInfoEx/src/ctrl_contact.cpp +++ b/plugins/UserInfoEx/src/ctrl_contact.cpp @@ -983,7 +983,7 @@ static LRESULT CALLBACK CtrlContactWndProc(HWND hwnd, UINT msg, WPARAM wParam, L if (pItem->wMask & CBEXIM_CAT) {
// set category string
if (!pItem->pszCat || !pItem->pszCat[0] || !mir_tstrncpy(cbex->pItems[pItem->iItem].szCat, pItem->pszCat, SIZEOF(cbex->pItems[pItem->iItem].szCat)))
- mir_sntprintf(cbex->pItems[pItem->iItem].szCat, SIZEOF(cbex->pItems[pItem->iItem].szCat), _T("%s %d\0"), TranslateT("Other"), ++cbex->numOther);
+ mir_sntprintf(cbex->pItems[pItem->iItem].szCat, SIZEOF(cbex->pItems[pItem->iItem].szCat), _T("%s %d"), TranslateT("Other"), ++cbex->numOther);
if (pItem->iItem == cbex->iSelectedItem)
SetWindowText(cbex->hBtnEdit, cbex->pItems[pItem->iItem].szCat);
}
@@ -1284,20 +1284,17 @@ int CtrlContactAddItemFromDB( {
DBVARIANT dbv;
CBEXITEM cbi;
- LPTSTR sms;
cbi.pszVal = NULL;
cbi.dwID = hashSetting(szSettingVal);
cbi.wFlags = CBEXIF_CATREADONLY|DB::Setting::GetTStringCtrl(hContact, pszModule, pszModule, pszProto, szSettingVal, &dbv);
if (dbv.type >= DBVT_WCHAR) {
// no value read from database
- if (cbi.wFlags == CBEXIF_CATREADONLY) {
+ if (cbi.wFlags == CBEXIF_CATREADONLY)
cbi.pszVal = NULL;
- }
- // check the database value
- else {
+ else { // check the database value
cbi.pszVal = dbv.ptszVal;
- if (sms = _tcsstr(cbi.pszVal, _T(" SMS\0"))) {
+ if (LPTSTR sms = _tcsstr(cbi.pszVal, _T(" SMS"))) {
cbi.wFlags |= CBEXIF_SMS;
*sms = 0;
}
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp index d2d946001e..39ffd48918 100644 --- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp +++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp @@ -1060,7 +1060,7 @@ BYTE CVCardFileVCF::Export(BYTE bExportUtf) MAnnivDate mdb;
if (!mdb.DBGetBirthDate(_hContact, NULL))
- fprintf(_pFile, "BDAY:%d%02d%02d\n\0", mdb.Year(), mdb.Month(), mdb.Day());
+ fprintf(_pFile, "BDAY:%d%02d%02d\n", mdb.Year(), mdb.Month(), mdb.Day());
}
//
diff --git a/plugins/UserInfoEx/src/mir_db.cpp b/plugins/UserInfoEx/src/mir_db.cpp index f3704a0bf9..c55a2f4a43 100644 --- a/plugins/UserInfoEx/src/mir_db.cpp +++ b/plugins/UserInfoEx/src/mir_db.cpp @@ -30,17 +30,6 @@ namespace DB { namespace Contact {
/**
-* This function retrieves the display name for a contact.
-* @param hContact - handle to the contact
-* @return Returns the display name of a contact.
-**/
-
-LPTSTR DisplayName(MCONTACT hContact)
-{
- return pcli->pfnGetContactDisplayName(hContact, 0);
-}
-
-/**
* This function is used to retrieve a contact's basic protocol
* @param hContact - handle to the contact
* @return This function returns the basic protocol of a contact.
diff --git a/plugins/UserInfoEx/src/mir_db.h b/plugins/UserInfoEx/src/mir_db.h index 93df0f2a36..a11d01dca1 100644 --- a/plugins/UserInfoEx/src/mir_db.h +++ b/plugins/UserInfoEx/src/mir_db.h @@ -28,7 +28,10 @@ namespace DB { * or modify contacts in the database.
**/
namespace Contact {
- LPTSTR DisplayName(MCONTACT hContact);
+ __forceinline LPTSTR DisplayName(MCONTACT hContact)
+ { return pcli->pfnGetContactDisplayName(hContact, 0);
+ }
+
LPSTR Proto(MCONTACT hContact);
INT_PTR GetCount();
diff --git a/plugins/UserInfoEx/src/svc_avatar.cpp b/plugins/UserInfoEx/src/svc_avatar.cpp index 3530f28ec1..b81a5022a6 100644 --- a/plugins/UserInfoEx/src/svc_avatar.cpp +++ b/plugins/UserInfoEx/src/svc_avatar.cpp @@ -25,38 +25,28 @@ namespace NServices {
namespace NAvatar
{
-
static HANDLE ghChangedHook = NULL;
static int GetContactAvatarFileName(LPCTSTR zodiac, LPSTR szFileName, int cchFileName)
{
- if (!CallService(MS_DB_GETPROFILEPATH, (WPARAM)cchFileName, (LPARAM)szFileName))
- {
+ if (!CallService(MS_DB_GETPROFILEPATH, (WPARAM)cchFileName, (LPARAM)szFileName)) {
size_t len = mir_strlen(szFileName);
CHAR tmp[64];
-
- if (WideCharToMultiByte(CP_ACP, 0, zodiac, 64, tmp, SIZEOF(tmp),0,0) > 0)
- {
+ if (WideCharToMultiByte(CP_ACP, 0, zodiac, 64, tmp, SIZEOF(tmp), 0, 0) > 0)
mir_snprintf(szFileName + len, cchFileName - len, "\\avatars\\%s.png", tmp);
- }
return !PathFileExistsA(szFileName);
}
return 1;
}
- /**
- *
- *
- **/
static void SetZodiacAvatar(MCONTACT hContact)
{
MAnnivDate mtb;
// try to load birthday for contact
- if (!mtb.DBGetBirthDate(hContact))
- {
+ if (!mtb.DBGetBirthDate(hContact)) {
MZodiac zodiac;
//ICONINFO iinfo;
CHAR szFileName[MAX_PATH];
@@ -64,8 +54,7 @@ namespace NServices // get zodiac for birthday
zodiac = mtb.Zodiac();
- if (!GetContactAvatarFileName(zodiac.pszName, szFileName, SIZEOF(szFileName)))
- {
+ if (!GetContactAvatarFileName(zodiac.pszName, szFileName, SIZEOF(szFileName))) {
// extract the bitmap from the icon
//GetIconInfo(zodiac.hIcon, &iinfo);
@@ -78,8 +67,7 @@ namespace NServices void DeleteAvatar(MCONTACT hContact)
{
- if (hContact && db_get_b(hContact, "ContactPhoto", "IsZodiac", FALSE))
- {
+ if (hContact && db_get_b(hContact, "ContactPhoto", "IsZodiac", FALSE)) {
db_unset(hContact, "ContactPhoto", "File");
db_unset(hContact, "ContactPhoto", "RFile");
db_unset(hContact, "ContactPhoto", "Backup");
@@ -89,23 +77,15 @@ namespace NServices }
}
-
- /**
- *
- *
- **/
static int OnAvatarChanged(MCONTACT hContact, AVATARCACHEENTRY *ace)
{
- if (hContact)
- {
+ if (hContact) {
// check valid parameters
- if (ace)
- {
+ if (ace) {
if (// check for correct structure
- ace->cbSize == sizeof(AVATARCACHEENTRY) &&
- // set zodiac as avatar either if the desired avatar is invalid or a general protocol picture
- ((ace->dwFlags & AVS_PROTOPIC) || !(ace->dwFlags & AVS_BITMAP_VALID)))
- {
+ ace->cbSize == sizeof(AVATARCACHEENTRY) &&
+ // set zodiac as avatar either if the desired avatar is invalid or a general protocol picture
+ ((ace->dwFlags & AVS_PROTOPIC) || !(ace->dwFlags & AVS_BITMAP_VALID))) {
if (!db_get_b(hContact, "ContactPhoto", "IsZodiac", 0))
SetZodiacAvatar(hContact);
}
@@ -113,43 +93,29 @@ namespace NServices }
// avatar was deleted, so we can set up a zodiac avatar
- else
- {
- SetZodiacAvatar(hContact);
- }
+ else SetZodiacAvatar(hContact);
}
return 0;
}
- /**
- *
- *
- **/
void Enable(BYTE bEnable)
{
- MCONTACT hContact;
DBVARIANT dbv;
- if (bEnable && !ghChangedHook)
- {
+ if (bEnable && !ghChangedHook) {
- //walk through all the contacts stored in the DB
- for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
- {
+ // walk through all the contacts stored in the DB
+ for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact)) {
// don't set if avatar is locked!
- if (!db_get_b(hContact, "ContactPhoto", "Locked", 0))
- {
+ if (!db_get_b(hContact, "ContactPhoto", "Locked", 0)) {
BYTE bInvalidAvatar = TRUE;
// the relative file is valid
- if (!DB::Setting::GetAString(hContact, "ContactPhoto", "RFile", &dbv))
- {
- CHAR absolute[MAX_PATH];
- absolute[0] = '\0';
+ if (!DB::Setting::GetAString(hContact, "ContactPhoto", "RFile", &dbv)) {
+ CHAR absolute[MAX_PATH]; absolute[0] = 0;
// check if file exists
- if ( !PathToAbsolute(dbv.pszVal, absolute))
- {
+ if (!PathToAbsolute(dbv.pszVal, absolute)) {
FILE *f = fopen(absolute, "rb");
if (f) {
bInvalidAvatar = FALSE;
@@ -160,8 +126,7 @@ namespace NServices }
// the absolute file is valid
- if (bInvalidAvatar && !db_get(hContact, "ContactPhoto", "File", &dbv))
- {
+ if (bInvalidAvatar && !db_get(hContact, "ContactPhoto", "File", &dbv)) {
FILE *f = fopen(dbv.pszVal, "rb");
if (f) {
bInvalidAvatar = FALSE;
@@ -171,25 +136,22 @@ namespace NServices }
// set the zodiac as avatar
- if (bInvalidAvatar) {
+ if (bInvalidAvatar)
SetZodiacAvatar(hContact);
- }
}
}
- ghChangedHook = HookEvent(ME_AV_AVATARCHANGED, (MIRANDAHOOK) OnAvatarChanged);
+ ghChangedHook = HookEvent(ME_AV_AVATARCHANGED, (MIRANDAHOOK)OnAvatarChanged);
}
- else if (!bEnable && ghChangedHook)
- {
+ else if (!bEnable && ghChangedHook) {
UnhookEvent(ghChangedHook);
ghChangedHook = NULL;
- //walk through all the contacts stored in the DB
- for (hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
+ // walk through all the contacts stored in the DB
+ for (MCONTACT hContact = db_find_first(); hContact != NULL; hContact = db_find_next(hContact))
DeleteAvatar(hContact);
}
}
-
/**
* name: OnModulesLoaded
* desc: initialize stuff, which require all standard modules to bee loaded
diff --git a/plugins/UserInfoEx/src/svc_reminder.cpp b/plugins/UserInfoEx/src/svc_reminder.cpp index f8633d1622..51d39c7d86 100644 --- a/plugins/UserInfoEx/src/svc_reminder.cpp +++ b/plugins/UserInfoEx/src/svc_reminder.cpp @@ -383,17 +383,14 @@ static BYTE CheckAnniversaries(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE int numAnniversaries = 0;
int Diff;
MAnnivDate mta;
- TCHAR szAnniv[MAX_PATH];
- TCHAR strMsg[MAX_SECONDLINE];
- BYTE bOverflow = FALSE;
- WORD wDaysEarlier;
+ CMString tszMsg;
if (gRemindOpts.RemindState == REMIND_ANNIV || gRemindOpts.RemindState == REMIND_ALL) {
for (int i = 0; i < ANID_LAST && !mta.DBGetAnniversaryDate(hContact, i); i++) {
mta.DBGetReminderOpts(hContact);
if (mta.RemindOption() != BST_UNCHECKED) {
- wDaysEarlier = (mta.RemindOption() == BST_CHECKED) ? mta.RemindOffset() : -1;
+ WORD wDaysEarlier = (mta.RemindOption() == BST_CHECKED) ? mta.RemindOffset() : -1;
if (wDaysEarlier == (WORD)-1)
wDaysEarlier = gRemindOpts.wDaysEarlier;
@@ -406,39 +403,21 @@ static BYTE CheckAnniversaries(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE numAnniversaries++;
// create displayed text for popup
- if (bNotify && !bOverflow) {
+ if (bNotify) {
// first anniversary found
- if (numAnniversaries == 1) {
- mir_sntprintf(szAnniv, SIZEOF(szAnniv),
- TranslateT("%s has the following anniversaries:\0"),
- ContactGender(hContact));
- mir_tstrncpy(strMsg, szAnniv, mir_tstrlen(szAnniv));
- }
+ if (numAnniversaries == 1)
+ tszMsg.AppendFormat(TranslateT("%s has the following anniversaries:"), ContactGender(hContact));
+ tszMsg.Append(_T("\n- "));
switch (Diff) {
case 0:
- mir_sntprintf(szAnniv, SIZEOF(szAnniv), TranslateT("%d. %s today\0"), mta.Age(), mta.Description());
+ tszMsg.AppendFormat(TranslateT("%d. %s today"), mta.Age(), mta.Description());
break;
case 1:
- mir_sntprintf(szAnniv, SIZEOF(szAnniv), TranslateT("%d. %s tomorrow\0"), mta.Age() + 1, mta.Description());
+ tszMsg.AppendFormat(TranslateT("%d. %s tomorrow"), mta.Age() + 1, mta.Description());
break;
default:
- mir_sntprintf(szAnniv, SIZEOF(szAnniv), TranslateT("%d. %s in %d days\0"), mta.Age() + 1, mta.Description(), Diff);
- }
-
- if (mir_tstrlen(szAnniv) >= MAX_SECONDLINE - mir_tstrlen(strMsg)) {
- if (strMsg)
- mir_tstrncat(strMsg, _T("\n...\0"), SIZEOF(strMsg));
- else
- mir_tstrncpy(strMsg, _T("\n...\0"), mir_tstrlen(_T("\n...\0")));
- bOverflow = TRUE;
- }
- else {
- if (strMsg)
- mir_tstrncat(strMsg, _T("\n- \0"), SIZEOF(strMsg));
- else
- mir_tstrncpy(strMsg, _T("\n- \0"), mir_tstrlen(_T("\n- \0")));
- mir_tstrncat(strMsg, szAnniv, SIZEOF(strMsg));
+ tszMsg.AppendFormat(TranslateT("%d. %s in %d days"), mta.Age() + 1, mta.Description(), Diff);
}
}
}
@@ -447,8 +426,14 @@ static BYTE CheckAnniversaries(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE }
// show one popup for all anniversaries
- if (numAnniversaries != 0 && bNotify)
- NotifyWithPopup(hContact, CEvent::ANNIVERSARY, Diff, LPGENT("Anniversaries"), strMsg);
+ if (numAnniversaries != 0 && bNotify) {
+ if (tszMsg.GetLength() >= MAX_SECONDLINE) {
+ tszMsg.Truncate(MAX_SECONDLINE - 5);
+ tszMsg.Append(_T("\n..."));
+ }
+
+ NotifyWithPopup(hContact, CEvent::ANNIVERSARY, Diff, LPGENT("Anniversaries"), tszMsg);
+ }
return numAnniversaries != 0;
}
@@ -466,15 +451,12 @@ static BYTE CheckAnniversaries(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE * @retval FALSE - contact has no birthday or it is not within the desired period of time.
**/
-static BYTE CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE bNotify, PWORD LastAnwer)
+static bool CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE bNotify, PWORD LastAnwer)
{
- BYTE result = FALSE;
-
if (gRemindOpts.RemindState == REMIND_BIRTH || gRemindOpts.RemindState == REMIND_ALL) {
MAnnivDate mtb;
if (!mtb.DBGetBirthDate(hContact)) {
int Diff;
- WORD wDaysEarlier;
mtb.DBGetReminderOpts(hContact);
@@ -483,7 +465,7 @@ static BYTE CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE bNoti mtb.BackupBirthday(hContact, NULL, 0, LastAnwer);
if (mtb.RemindOption() != BST_UNCHECKED) {
- wDaysEarlier = (mtb.RemindOption() == BST_CHECKED) ? mtb.RemindOffset() : -1;
+ WORD wDaysEarlier = (mtb.RemindOption() == BST_CHECKED) ? mtb.RemindOffset() : -1;
if (wDaysEarlier == (WORD)-1)
wDaysEarlier = gRemindOpts.wDaysEarlier;
@@ -516,12 +498,12 @@ static BYTE CheckBirthday(MCONTACT hContact, MTime &Now, CEvent &evt, BYTE bNoti NotifyWithPopup(hContact, CEvent::BIRTHDAY, Diff, mtb.Description(), szMsg);
}
- result = TRUE;
+ return true;
}
}
}
}
- return result;
+ return false;
}
/**
|