summaryrefslogtreecommitdiff
path: root/plugins/SmileyAdd
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/SmileyAdd')
-rw-r--r--plugins/SmileyAdd/src/options.cpp47
-rw-r--r--plugins/SmileyAdd/src/services.cpp2
-rw-r--r--plugins/SmileyAdd/src/smileys.cpp37
-rw-r--r--plugins/SmileyAdd/src/smileys.h6
4 files changed, 72 insertions, 20 deletions
diff --git a/plugins/SmileyAdd/src/options.cpp b/plugins/SmileyAdd/src/options.cpp
index 5fb0abf771..03ff09c3ae 100644
--- a/plugins/SmileyAdd/src/options.cpp
+++ b/plugins/SmileyAdd/src/options.cpp
@@ -41,6 +41,7 @@ private:
void FilenameChanged(void);
void ShowSmileyPreview(void);
void PopulateSmPackList(void);
+ void UpdateVisibleSmPackList(void);
void UserAction(HTREEITEM hItem);
long GetSelProto(HTREEITEM hItem = NULL);
@@ -266,7 +267,8 @@ void OptionsDialogType::UserAction(HTREEITEM hItem)
if (!BrowseForSmileyPacks(GetSelProto(hItem)))
TreeView_SetCheckState(hLstView, hItem, TRUE)
}
- else tmpsmcat.GetSmileyCategory(GetSelProto(hItem))->ClearFilename();
+ else
+ tmpsmcat.GetSmileyCategory(GetSelProto(hItem))->ClearFilename();
if (hItem == TreeView_GetSelection(hLstView))
UpdateControls();
@@ -274,6 +276,7 @@ void OptionsDialogType::UserAction(HTREEITEM hItem)
TreeView_SelectItem(hLstView, hItem);
SetChanged();
+ PopulateSmPackList();
}
@@ -317,12 +320,42 @@ long OptionsDialogType::GetSelProto(HTREEITEM hItem)
return (long)tvi.lParam;
}
-
-void OptionsDialogType::PopulateSmPackList(void)
+void OptionsDialogType::UpdateVisibleSmPackList(void)
{
bool useOne = IsDlgButtonChecked(m_hwndDialog, IDC_USESTDPACK) == BST_UNCHECKED;
bool usePhysProto = IsDlgButtonChecked(m_hwndDialog, IDC_USEPHYSPROTO) == BST_CHECKED;
+ SmileyCategoryListType::SmileyCategoryVectorType& smc = *tmpsmcat.GetSmileyCategoryList();
+ for (int i = 0; i < smc.getCount(); i++) {
+ bool visiblecat = usePhysProto ? !smc[i].IsAcc() : !smc[i].IsPhysProto();
+ bool visible = useOne ? !smc[i].IsProto() : visiblecat;
+
+ if (!visible && smc[i].IsAcc()) {
+ CMString PhysProtoName = _T("AllProto");
+ CMString ProtoName = smc[i].GetName();
+ DBVARIANT dbv;
+ if (db_get_ts(NULL, T2A_SM(ProtoName.GetBuffer()), "AM_BaseProto", &dbv) == 0){
+ ProtoName = dbv.ptszVal;
+ db_free(&dbv);
+ }
+ else
+ ProtoName.Empty();
+
+ CMString FileName;
+ if (!ProtoName.IsEmpty()) {
+ PhysProtoName += PhysProtoName;
+ FileName = tmpsmcat.GetSmileyCategory(PhysProtoName)->GetFilename();
+ if (FileName.IsEmpty())
+ visible = true;
+ }
+ }
+
+ smc[i].SetVisible(visible);
+ }
+}
+
+void OptionsDialogType::PopulateSmPackList(void)
+{
HWND hLstView = GetDlgItem(m_hwndDialog, IDC_CATEGORYLIST);
TreeView_SelectItem(hLstView, NULL);
@@ -333,12 +366,10 @@ void OptionsDialogType::PopulateSmPackList(void)
tvi.hInsertAfter = TVI_LAST;
tvi.item.mask = TVIF_TEXT | TVIF_IMAGE | TVIF_STATE | TVIF_SELECTEDIMAGE | TVIF_PARAM;
tvi.item.stateMask = TVIS_STATEIMAGEMASK | TVIS_SELECTED;
-
+ UpdateVisibleSmPackList();
SmileyCategoryListType::SmileyCategoryVectorType& smc = *tmpsmcat.GetSmileyCategoryList();
- for (int i=0; i < smc.getCount(); i++) {
- bool visiblecat = usePhysProto ? !smc[i].IsAcc() : !smc[i].IsPhysProto();
- bool visible = useOne ? !smc[i].IsProto() : visiblecat;
- if (visible) {
+ for (int i=0; i < smc.getCount(); i++) {
+ if (smc[i].IsVisible()) {
tvi.item.pszText = (TCHAR*)smc[i].GetDisplayName().c_str();
if (!smc[i].IsProto()) {
tvi.item.iImage = 0;
diff --git a/plugins/SmileyAdd/src/services.cpp b/plugins/SmileyAdd/src/services.cpp
index 0ada278cb0..a250bf10bb 100644
--- a/plugins/SmileyAdd/src/services.cpp
+++ b/plugins/SmileyAdd/src/services.cpp
@@ -54,6 +54,8 @@ SmileyPackType* GetSmileyPack(const char* proto, MCONTACT hContact, SmileyPackCT
categoryName = _T("AllProto");
categoryName += dbv.ptszVal;
db_free(&dbv);
+ if (g_SmileyCategories.GetSmileyCategory(categoryName)->GetFilename().IsEmpty())
+ categoryName = A2T_SM(protonam);
}
else
categoryName = A2T_SM(protonam);
diff --git a/plugins/SmileyAdd/src/smileys.cpp b/plugins/SmileyAdd/src/smileys.cpp
index a8c2240b89..c2a18de08f 100644
--- a/plugins/SmileyAdd/src/smileys.cpp
+++ b/plugins/SmileyAdd/src/smileys.cpp
@@ -724,6 +724,7 @@ SmileyCategoryType::SmileyCategoryType(SmileyPackListType* pSPS, const CMString&
type = typ;
m_Name = name;
m_DisplayName = displayName;
+ visible = true;
opt.ReadPackFileName(m_Filename, m_Name, defaultFilename);
}
@@ -834,21 +835,35 @@ void SmileyCategoryListType::AddAccountAsCategory(PROTOACCOUNT *acc, const CMStr
if (IsAccountEnabled(acc) && acc->szProtoName && IsSmileyProto(acc->szModuleName))
{
CMString displayName(acc->tszAccountName ? acc->tszAccountName : A2T_SM(acc->szModuleName));
+ CMString PhysProtoName, paths;
+ DBVARIANT dbv;
+
+ if (db_get_ts(NULL, acc->szModuleName, "AM_BaseProto", &dbv) == 0){
+ PhysProtoName = _T("AllProto");
+ PhysProtoName += dbv.ptszVal;
+ db_free(&dbv);
+ }
- const char* packnam = acc->szProtoName;
- if (strcmp(packnam, "JABBER") == 0)
- packnam = "JGMail";
- else if (strstr(packnam, "SIP") != NULL)
- packnam = "MSN";
+ if (!PhysProtoName.IsEmpty())
+ paths = g_SmileyCategories.GetSmileyCategory(PhysProtoName)->GetFilename();
+
+ if (paths.IsEmpty()){
+ const char* packnam = acc->szProtoName;
+ if (strcmp(packnam, "JABBER") == 0)
+ packnam = "JGMail";
+ else if (strstr(packnam, "SIP") != NULL)
+ packnam = "MSN";
- char path[MAX_PATH];
- mir_snprintf(path, SIZEOF(path), "Smileys\\nova\\%s.msl", packnam);
+ char path[MAX_PATH];
+ mir_snprintf(path, SIZEOF(path), "Smileys\\nova\\%s.msl", packnam);
- CMString paths = A2T_SM(path), patha;
- pathToAbsolute(paths, patha);
+ paths = A2T_SM(path);
+ CMString patha;
+ pathToAbsolute(paths, patha);
- if (_taccess(patha.c_str(), 0) != 0)
- paths = defaultFile;
+ if (_taccess(patha.c_str(), 0) != 0)
+ paths = defaultFile;
+ }
CMString tname(A2T_SM(acc->szModuleName));
AddCategory(tname, displayName, smcProto, paths);
diff --git a/plugins/SmileyAdd/src/smileys.h b/plugins/SmileyAdd/src/smileys.h
index fce65fffa2..5a27cd37c0 100644
--- a/plugins/SmileyAdd/src/smileys.h
+++ b/plugins/SmileyAdd/src/smileys.h
@@ -243,8 +243,10 @@ private:
SmileyPackListType* m_pSmileyPackStore;
+ bool visible;
+
public:
- SmileyCategoryType() { type = smcNone; m_pSmileyPackStore = NULL; };
+ SmileyCategoryType() { type = smcNone; m_pSmileyPackStore = NULL; visible = true; };
SmileyCategoryType(SmileyPackListType* pSPS, const CMString& name,
const CMString& displayName, const CMString& defaultFilename, SmcType typ);
@@ -258,6 +260,7 @@ public:
bool IsPhysProto(void) { return type == smcPhysProto; }
bool IsTransportProto(void) { return type == smcTransportProto; }
bool IsExt(void) { return type == smcExt; }
+ bool IsVisible(void) { return visible; }
SmcType GetType(void) { return type; }
@@ -265,6 +268,7 @@ public:
void SetFilename(CMString& name) { m_Filename = name; }
void SetDisplayName(CMString& name) { m_DisplayName = name; }
+ void SetVisible(bool vis) { visible = vis; }
void ClearFilename(void) { m_Filename.Empty(); }
void SaveSettings(void);