summaryrefslogtreecommitdiff
path: root/src/mir_app
diff options
context:
space:
mode:
Diffstat (limited to 'src/mir_app')
-rw-r--r--src/mir_app/mir_app.mk7
-rw-r--r--src/mir_app/mir_app.project1
-rw-r--r--src/mir_app/src/addcontact.cpp2
-rw-r--r--src/mir_app/src/auth.cpp98
4 files changed, 65 insertions, 43 deletions
diff --git a/src/mir_app/mir_app.mk b/src/mir_app/mir_app.mk
index 67afc86242..d18c70358f 100644
--- a/src/mir_app/mir_app.mk
+++ b/src/mir_app/mir_app.mk
@@ -62,7 +62,7 @@ AS := as
## User defined environment variables
##
CodeLiteDir:=/usr/share/codelite
-Objects0=$(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_events.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_CMPluginBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_addcontact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_stdafx.cxx$(ObjectSuffix)
+Objects0=$(IntermediateDirectory)/src_auth.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_intf.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_db_events.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_database.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_contact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_CMPluginBase.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_addcontact.cpp$(ObjectSuffix) $(IntermediateDirectory)/src_stdafx.cxx$(ObjectSuffix)
@@ -94,6 +94,11 @@ PreBuild:
##
## Objects
##
+$(IntermediateDirectory)/src_auth.cpp$(ObjectSuffix): src/auth.cpp
+ $(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/auth.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_auth.cpp$(ObjectSuffix) $(IncludePath)
+$(IntermediateDirectory)/src_auth.cpp$(PreprocessSuffix): src/auth.cpp
+ $(CXX) $(CXXFLAGS) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/src_auth.cpp$(PreprocessSuffix) src/auth.cpp
+
$(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix): src/miranda.cpp
$(CXX) $(IncludePCH) $(SourceSwitch) "/home/ghazan/miranda-ng/src/mir_app/src/miranda.cpp" $(CXXFLAGS) $(ObjectSwitch)$(IntermediateDirectory)/src_miranda.cpp$(ObjectSuffix) $(IncludePath)
$(IntermediateDirectory)/src_miranda.cpp$(PreprocessSuffix): src/miranda.cpp
diff --git a/src/mir_app/mir_app.project b/src/mir_app/mir_app.project
index 121dc016a2..309d857480 100644
--- a/src/mir_app/mir_app.project
+++ b/src/mir_app/mir_app.project
@@ -3,6 +3,7 @@
<Description/>
<Dependencies/>
<VirtualDirectory Name="src">
+ <File Name="src/auth.cpp"/>
<File Name="src/miranda.cpp"/>
<File Name="src/database.cpp"/>
<File Name="src/db_intf.cpp"/>
diff --git a/src/mir_app/src/addcontact.cpp b/src/mir_app/src/addcontact.cpp
index 0e97ec518d..afefeda2b4 100644
--- a/src/mir_app/src/addcontact.cpp
+++ b/src/mir_app/src/addcontact.cpp
@@ -182,7 +182,7 @@ MIR_APP_DLL(void) Contact_Add(MCONTACT hContact, HWND hwndParent)
else (new CAddByContact(hContact))->Show();
}
-MIR_APP_DLL(void) Contact_AddByEvent(MEVENT hEvent, HWND hwndParent)
+MIR_APP_DLL(void) Contact_AddByEvent(MEVENT hEvent, MWindow hwndParent)
{
struct CAddByEvent : public CAddContactDlg
{
diff --git a/src/mir_app/src/auth.cpp b/src/mir_app/src/auth.cpp
index 8c12b475ff..ae838e78b5 100644
--- a/src/mir_app/src/auth.cpp
+++ b/src/mir_app/src/auth.cpp
@@ -33,13 +33,19 @@ class CAuthReqDlg : public CDlgBase
MCONTACT m_hContact;
const char *m_szProto;
+ CCtrlBase fldHeader, fldReason;
+ CCtrlEdit edtReason;
CCtrlCheck chkAdd;
- CCtrlButton btnDetails, btnLater;
+ CCtrlButton btnAdd, btnDetails, btnLater;
public:
CAuthReqDlg(MEVENT hEvent) :
CDlgBase(g_plugin, IDD_AUTHREQ),
m_hDbEvent(hEvent),
+ fldHeader(this, IDC_HEADERBAR),
+ fldReason(this, IDC_REASON),
+ edtReason(this, IDC_DENYREASON),
+ btnAdd(this, IDC_ADD),
btnLater(this, IDC_DECIDELATER),
btnDetails(this, IDC_DETAILS),
chkAdd(this, IDC_ADDCHECK)
@@ -69,8 +75,10 @@ public:
char *email = last + mir_strlen(last) + 1;
char *reason = email + mir_strlen(email) + 1;
- SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
- SendMessage(m_hwnd, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ #ifdef _WINDOWS
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ #endif
ptrW lastT(dbei.flags & DBEF_UTF ? mir_utf8decodeW(last) : mir_a2u(last));
ptrW firstT(dbei.flags & DBEF_UTF ? mir_utf8decodeW(first) : mir_a2u(first));
@@ -78,43 +86,43 @@ public:
ptrW emailT(dbei.flags & DBEF_UTF ? mir_utf8decodeW(email) : mir_a2u(email));
ptrW reasonT(dbei.flags & DBEF_UTF ? mir_utf8decodeW(reason) : mir_a2u(reason));
- wchar_t name[128] = L"";
- int off = 0;
+ CMStringW wszName;
if (firstT[0] && lastT[0])
- off = mir_snwprintf(name, L"%s %s", (wchar_t*)firstT, (wchar_t*)lastT);
+ wszName.Format(L"%s %s", (wchar_t*)firstT, (wchar_t*)lastT);
else if (firstT[0])
- off = mir_snwprintf(name, L"%s", (wchar_t*)firstT);
+ wszName = firstT.get();
else if (lastT[0])
- off = mir_snwprintf(name, L"%s", (wchar_t*)lastT);
+ wszName = lastT.get();
+
if (mir_wstrlen(nickT)) {
- if (off)
- mir_snwprintf(name + off, _countof(name) - off, L" (%s)", (wchar_t*)nickT);
+ if (wszName.IsEmpty())
+ wszName = nickT.get();
else
- wcsncpy_s(name, nickT, _TRUNCATE);
+ wszName.AppendFormat(L" %s", nickT.get());
}
- if (!name[0])
- wcsncpy_s(name, TranslateT("<Unknown>"), _TRUNCATE);
+ if (wszName.IsEmpty())
+ wszName = TranslateT("<Unknown>");
PROTOACCOUNT *acc = Proto_GetAccount(dbei.szModule);
wchar_t hdr[256];
if (uin && emailT[0])
- mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u (%s) on %s"), name, uin, (wchar_t*)emailT, acc->tszAccountName);
+ mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u (%s) on %s"), wszName.c_str(), uin, (wchar_t*)emailT, acc->tszAccountName);
else if (uin)
- mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u on %s"), name, uin, acc->tszAccountName);
+ mir_snwprintf(hdr, TranslateT("%s requested authorization\n%u on %s"), wszName.c_str(), uin, acc->tszAccountName);
else
- mir_snwprintf(hdr, TranslateT("%s requested authorization\n%s on %s"), name, emailT[0] ? (wchar_t*)emailT : TranslateT("(Unknown)"), acc->tszAccountName);
+ mir_snwprintf(hdr, TranslateT("%s requested authorization\n%s on %s"), wszName.c_str(), emailT[0] ? (wchar_t*)emailT : TranslateT("(Unknown)"), acc->tszAccountName);
- SetDlgItemText(m_hwnd, IDC_HEADERBAR, hdr);
- SetDlgItemText(m_hwnd, IDC_REASON, reasonT);
+ fldHeader.SetText(hdr);
+ fldReason.SetText(reasonT);
if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact))
- ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
+ btnAdd.Hide();
- SendDlgItemMessage(m_hwnd, IDC_DENYREASON, EM_LIMITTEXT, 255, 0);
+ edtReason.SetMaxLength(255);
if (CallProtoService(dbei.szModule, PS_GETCAPS, PFLAGNUM_4, 0) & PF4_NOAUTHDENYREASON) {
- EnableWindow(GetDlgItem(m_hwnd, IDC_DENYREASON), FALSE);
- SetDlgItemText(m_hwnd, IDC_DENYREASON, TranslateT("Feature is not supported by protocol"));
+ edtReason.Disable();
+ edtReason.SetText(TranslateT("Feature is not supported by protocol"));
}
if (Contact_OnList(m_hContact)) {
@@ -137,18 +145,19 @@ public:
void OnDestroy() override
{
if (!m_bSucceeded) {
- if (IsWindowEnabled(GetDlgItem(m_hwnd, IDC_DENYREASON))) {
- wchar_t tszReason[256];
- GetDlgItemText(m_hwnd, IDC_DENYREASON, tszReason, _countof(tszReason));
- CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, (LPARAM)tszReason);
- }
- else CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, 0);
+ if (edtReason.Enabled())
+ CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, (LPARAM)ptrW(edtReason.GetText()));
+ else
+ CallProtoService(m_szProto, PS_AUTHDENY, m_hDbEvent, 0);
}
Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD);
Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS);
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
+
+ #ifdef _WINDOWS
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
+ #endif
}
void onClick_Later(CCtrlButton*)
@@ -176,6 +185,7 @@ class CAddedDlg : public CDlgBase
MEVENT m_hDbEvent;
MCONTACT m_hContact;
+ CCtrlBase fldHeader;
CCtrlButton btnDetails, btnAdd;
public:
@@ -183,7 +193,8 @@ public:
CDlgBase(g_plugin, IDD_ADDED),
m_hDbEvent(hEvent),
btnAdd(this, IDC_ADD),
- btnDetails(this, IDC_DETAILS)
+ btnDetails(this, IDC_DETAILS),
+ fldHeader(this, IDC_HEADERBAR)
{
btnAdd.OnClick = Callback(this, &CAddedDlg::onClick_Add);
btnDetails.OnClick = Callback(this, &CAddedDlg::onClick_Details);
@@ -201,14 +212,16 @@ public:
m_hContact = DbGetAuthEventContact(&dbei);
- uint32_t uin = *(PDWORD)dbei.pBlob;
+ uint32_t uin = *(uint32_t*)dbei.pBlob;
char* nick = (char*)dbei.pBlob + sizeof(uint32_t) * 2;
char* first = nick + mir_strlen(nick) + 1;
char* last = first + mir_strlen(first) + 1;
char* email = last + mir_strlen(last) + 1;
- SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
- SendMessage(m_hwnd, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ #ifdef _WINDOWS
+ SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_SMALL, 0));
+ SendMessage(m_hwnd, WM_SETICON, ICON_BIG, CallProtoService(dbei.szModule, PS_LOADICON, PLI_PROTOCOL | PLIF_LARGE, 0));
+ #endif
PROTOACCOUNT* acc = Proto_GetAccount(dbei.szModule);
@@ -241,10 +254,10 @@ public:
mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%u on %s"), name, uin, acc->tszAccountName);
else
mir_snwprintf(hdr, TranslateT("%s added you to the contact list\n%s on %s"), name, emailT[0] ? emailT.get() : TranslateT("(Unknown)"), acc->tszAccountName);
- SetDlgItemText(m_hwnd, IDC_HEADERBAR, hdr);
+ fldHeader.SetText(hdr);
if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact))
- ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
+ btnAdd.Hide();
return true;
}
@@ -258,8 +271,11 @@ public:
{
Button_FreeIcon_IcoLib(m_hwnd, IDC_ADD);
Button_FreeIcon_IcoLib(m_hwnd, IDC_DETAILS);
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
- DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
+
+ #ifdef _WINDOWS
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_BIG, 0));
+ DestroyIcon((HICON)SendMessage(m_hwnd, WM_SETICON, ICON_SMALL, 0));
+ #endif
}
void onClick_Add(CCtrlButton*)
@@ -267,7 +283,7 @@ public:
Contact_AddByEvent(m_hDbEvent, m_hwnd);
if (m_hContact == INVALID_CONTACT_ID || Contact_OnList(m_hContact))
- ShowWindow(GetDlgItem(m_hwnd, IDC_ADD), FALSE);
+ btnAdd.Hide();
}
void onClick_Details(CCtrlButton*)
@@ -316,7 +332,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
if (szUid)
mir_snwprintf(szTooltip, TranslateT("%s requests authorization"), szUid.get());
else
- mir_snwprintf(szTooltip, TranslateT("%u requests authorization"), *(PDWORD)dbei.pBlob);
+ mir_snwprintf(szTooltip, TranslateT("%u requests authorization"), *(uint32_t*)dbei.pBlob);
cle.hIcon = Skin_LoadIcon(SKINICON_AUTH_REQUEST);
cle.pszService = MS_AUTH_SHOWREQUEST;
@@ -327,7 +343,7 @@ static int AuthEventAdded(WPARAM, LPARAM lParam)
if (szUid)
mir_snwprintf(szTooltip, TranslateT("%s added you to their contact list"), szUid.get());
else
- mir_snwprintf(szTooltip, TranslateT("%u added you to their contact list"), *(PDWORD)dbei.pBlob);
+ mir_snwprintf(szTooltip, TranslateT("%u added you to their contact list"), *(uint32_t*)dbei.pBlob);
cle.hIcon = Skin_LoadIcon(SKINICON_AUTH_ADD);
cle.pszService = MS_AUTH_SHOWADDED;