summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/Actman/iac_contact.pas50
-rw-r--r--plugins/Clist_nicer/src/extBackg.cpp2
-rw-r--r--plugins/Import/src/import.cpp45
-rw-r--r--plugins/Import/src/stdafx.h1
-rw-r--r--plugins/MirLua/src/Modules/m_message.cpp2
-rw-r--r--plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp22
-rw-r--r--plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp2
-rw-r--r--plugins/Utils.pas/mircontacts.pas110
-rw-r--r--plugins/Variables/src/contact.cpp9
9 files changed, 75 insertions, 168 deletions
diff --git a/plugins/Actman/iac_contact.pas b/plugins/Actman/iac_contact.pas
index bf19f02020..a1bd4b1577 100644
--- a/plugins/Actman/iac_contact.pas
+++ b/plugins/Actman/iac_contact.pas
@@ -88,41 +88,31 @@ begin
proto:=Proto_GetBaseAccountName(hContact);
if proto<>nil then
begin
- is_chat:=IsChat(hContact);
- if is_chat then
+ uid:=Proto_GetUniqueId(proto);
+ if DBReadSetting(hContact,proto,uid,@cws)=0 then
begin
- p:=DBReadUnicode(hContact,proto,'ChatRoomID');
- node.AddTextW('id',p);
- mFreeMem(p);
result:=1;
- end
- else
- begin
- uid:=Proto_GetUniqueId(proto);
- if DBReadSetting(hContact,proto,uid,@cws)=0 then
- begin
- result:=1;
- node.AddDWord('ctype',cws._type);
- case cws._type of
- DBVT_BYTE : node.AddDWord('id',cws.bVal);
- DBVT_WORD : node.AddDWord('id',cws.wVal);
- DBVT_DWORD : node.AddDWord('id',cws.dVal);
- DBVT_ASCIIZ: begin
- node.AddText('id',cws.szVal.A); // ansi to utf
- end;
- DBVT_UTF8 : begin
- node.AddText('id',cws.szVal.A);
- end;
- DBVT_WCHAR : node.AddTextW('id',cws.szVal.W);
- DBVT_BLOB : begin
- p1:=mir_base64_encode(cws.pbVal,cws.cpbVal);
- node.AddText('id',p1);
- mir_free(p1);
- end;
+ node.AddDWord('ctype',cws._type);
+ case cws._type of
+ DBVT_BYTE : node.AddDWord('id',cws.bVal);
+ DBVT_WORD : node.AddDWord('id',cws.wVal);
+ DBVT_DWORD : node.AddDWord('id',cws.dVal);
+ DBVT_ASCIIZ: begin
+ node.AddText('id',cws.szVal.A); // ansi to utf
+ end;
+ DBVT_UTF8 : begin
+ node.AddText('id',cws.szVal.A);
+ end;
+ DBVT_WCHAR : node.AddTextW('id',cws.szVal.W);
+ DBVT_BLOB : begin
+ p1:=mir_base64_encode(cws.pbVal,cws.cpbVal);
+ node.AddText('id',p1);
+ mir_free(p1);
end;
end;
- db_free(@cws);
end;
+ db_free(@cws);
+
if result<>0 then
begin
node.AddText('protocol',proto);
diff --git a/plugins/Clist_nicer/src/extBackg.cpp b/plugins/Clist_nicer/src/extBackg.cpp
index 5655d67a07..b16188fcdb 100644
--- a/plugins/Clist_nicer/src/extBackg.cpp
+++ b/plugins/Clist_nicer/src/extBackg.cpp
@@ -1315,7 +1315,7 @@ void LoadPerContactSkins(wchar_t *tszFileName)
continue;
const char *uid = Proto_GetUniqueId(szProto);
- if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid != nullptr) {
+ if (uid != nullptr) {
DBVARIANT dbv = { 0 };
if (db_get(hContact, szProto, uid, &dbv))
break;
diff --git a/plugins/Import/src/import.cpp b/plugins/Import/src/import.cpp
index 17aeaa073a..3fd7b23161 100644
--- a/plugins/Import/src/import.cpp
+++ b/plugins/Import/src/import.cpp
@@ -95,20 +95,6 @@ MCONTACT CImportBatch::HContactFromID(const char *pszProtoName, const char *pszS
return INVALID_CONTACT_ID;
}
-MCONTACT CImportBatch::HContactFromChatID(const char *pszProtoName, const wchar_t *pszChatID)
-{
- for (MCONTACT hContact = dstDb->FindFirstContact(pszProtoName); hContact; hContact = dstDb->FindNextContact(hContact, pszProtoName)) {
- if (!Contact::IsGroupChat(hContact, pszProtoName))
- continue;
-
- ptrW wszChatId(db_get_wsa(hContact, pszProtoName, "ChatRoomID"));
- if (!mir_wstrcmp(pszChatID, wszChatId))
- return hContact;
- }
-
- return INVALID_CONTACT_ID;
-}
-
MCONTACT CImportBatch::HContactFromNumericID(const char *pszProtoName, const char *pszSetting, uint32_t dwID)
{
for (MCONTACT hContact = dstDb->FindFirstContact(pszProtoName); hContact; hContact = dstDb->FindNextContact(hContact, pszProtoName))
@@ -725,18 +711,11 @@ MCONTACT CImportBatch::ImportContact(MCONTACT hSrc)
return 0;
}
- // group chat?
- const char *pszUniqueSetting;
- bool bIsChat = myGetD(hSrc, cc->szProto, "ChatRoom", 0) != 0;
- if (bIsChat)
- pszUniqueSetting = "ChatRoomID";
- else {
- // Skip protocols with no unique id setting (some non IM protocols return 0)
- pszUniqueSetting = Proto_GetUniqueId(szDstModuleName);
- if (!pszUniqueSetting) {
- AddMessage(LPGENW("Skipping non-IM contact (%S)"), cc->szProto);
- return 0;
- }
+ // Skip protocols with no unique id setting (some non IM protocols return 0)
+ const char *pszUniqueSetting = Proto_GetUniqueId(szDstModuleName);
+ if (!pszUniqueSetting) {
+ AddMessage(LPGENW("Skipping non-IM contact (%S)"), cc->szProto);
+ return 0;
}
wchar_t *pszUniqueID = L"<Unknown>";
@@ -754,18 +733,12 @@ MCONTACT CImportBatch::ImportContact(MCONTACT hSrc)
case DBVT_ASCIIZ:
case DBVT_UTF8:
pszUniqueID = NEWWSTR_ALLOCA(_A2T(dbv.pszVal));
- if (bIsChat)
- hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
- else
- hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
+ hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
break;
case DBVT_WCHAR:
pszUniqueID = NEWWSTR_ALLOCA(dbv.pwszVal);
- if (bIsChat)
- hDst = HContactFromChatID(szDstModuleName, pszUniqueID);
- else
- hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
+ hDst = HContactFromID(szDstModuleName, pszUniqueSetting, pszUniqueID);
break;
default:
@@ -814,7 +787,7 @@ MCONTACT CImportBatch::ImportContact(MCONTACT hSrc)
srcDb->FreeVariant(&dbv);
- if (bIsChat)
+ if (myGetD(hSrc, cc->szProto, "ChatRoom", 0) != 0)
db_set_b(hDst, szDstModuleName, "ChatRoom", 1);
m_contacts.insert(new ContactMap(hSrc, hDst));
@@ -879,7 +852,7 @@ void CImportBatch::ImportHistory(MCONTACT hContact, PROTOACCOUNT **protocol, int
else hDst = NULL;
bool bSkipAll = false;
- uint32_t cbAlloc = 4096;
+ int cbAlloc = 4096;
uint8_t *eventBuf = (uint8_t*)mir_alloc(cbAlloc);
// Get the start of the event chain
diff --git a/plugins/Import/src/stdafx.h b/plugins/Import/src/stdafx.h
index b60d8402a5..3df8c0917a 100644
--- a/plugins/Import/src/stdafx.h
+++ b/plugins/Import/src/stdafx.h
@@ -285,7 +285,6 @@ class CImportBatch : public MZeroedObject
PROTOACCOUNT* FindMyAccount(const char *szProto, const char *szBaseProto, const wchar_t *ptszName, bool bStrict);
MCONTACT HContactFromID(const char *pszProtoName, const char *pszSetting, wchar_t *pwszID);
- MCONTACT HContactFromChatID(const char *pszProtoName, const wchar_t *pszChatID);
MCONTACT HContactFromNumericID(const char *pszProtoName, const char *pszSetting, uint32_t dwID);
public:
diff --git a/plugins/MirLua/src/Modules/m_message.cpp b/plugins/MirLua/src/Modules/m_message.cpp
index 289f82c935..a00ec285e1 100644
--- a/plugins/MirLua/src/Modules/m_message.cpp
+++ b/plugins/MirLua/src/Modules/m_message.cpp
@@ -28,7 +28,7 @@ static int message_Send(lua_State *L)
const char *szProto = Proto_GetBaseAccountName(hContact);
if (Contact::IsGroupChat(hContact, szProto)) {
- ptrW wszChatRoom(db_get_wsa(hContact, szProto, "ChatRoomID"));
+ ptrW wszChatRoom(Contact::GetInfo(CNF_UNIQUEID, hContact, szProto));
ptrW wszMessage(mir_utf8decodeW(message));
res = Chat_SendUserMessage(szProto, wszChatRoom, wszMessage);
lua_pushinteger(L, res);
diff --git a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
index 301d87c4f3..5393ae538b 100644
--- a/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
+++ b/plugins/UserInfoEx/src/ex_import/classExImContactBase.cpp
@@ -78,7 +78,6 @@ uint8_t CExImContactBase::fromDB(MCONTACT hContact)
uint8_t ret = FALSE;
uint8_t isChatRoom = FALSE;
LPSTR pszProto;
- LPCSTR uidSetting;
DBVARIANT dbv;
_hContact = hContact;
@@ -106,29 +105,16 @@ uint8_t CExImContactBase::fromDB(MCONTACT hContact)
db_free(&dbv);
}
- // unique id (for ChatRoom)
- if (isChatRoom = Contact::IsGroupChat(_hContact, pszProto)) {
- uidSetting = "ChatRoomID";
+ LPCSTR uidSetting = Proto_GetUniqueId(pszProto);
+ if (uidSetting != nullptr) { // valid
_pszUIDKey = mir_strdup(uidSetting);
if (!DB::Setting::GetAsIs(_hContact, pszProto, uidSetting, &_dbvUID)) {
ret = TRUE;
}
}
- // unique id (normal)
+ // fails because the protocol is no longer installed
else {
- uidSetting = Proto_GetUniqueId(pszProto);
- // valid
- if (uidSetting != nullptr && (INT_PTR)uidSetting != CALLSERVICE_NOTFOUND) {
- _pszUIDKey = mir_strdup(uidSetting);
- if (!DB::Setting::GetAsIs(_hContact, pszProto, uidSetting, &_dbvUID)) {
- ret = TRUE;
- }
- }
- // fails because the protocol is no longer installed
- else {
- // assert(ret == TRUE);
- ret = TRUE;
- }
+ ret = TRUE;
}
// nickname
diff --git a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp
index 1dc8fc82d4..14887c485d 100644
--- a/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp
+++ b/plugins/UserInfoEx/src/ex_import/svc_ExImVCF.cpp
@@ -1111,7 +1111,7 @@ uint8_t CVCardFileVCF::Export(uint8_t bExportUtf)
// contacts protocol, uin setting, uin value
//
LPCSTR uid = Proto_GetUniqueId(_pszBaseProto);
- if ((INT_PTR)uid != CALLSERVICE_NOTFOUND && uid) {
+ if (uid) {
CHAR szUID[MAXUID];
if (!db_get_static(_hContact, _pszBaseProto, uid, szUID, sizeof(szUID)))
fprintf(_pFile, "IM;%s;%s:%s\n", _pszBaseProto, uid, szUID);
diff --git a/plugins/Utils.pas/mircontacts.pas b/plugins/Utils.pas/mircontacts.pas
index 9a34525d24..583292702d 100644
--- a/plugins/Utils.pas/mircontacts.pas
+++ b/plugins/Utils.pas/mircontacts.pas
@@ -138,40 +138,28 @@ begin
hContact:=db_find_first();
while hContact<>0 do
begin
- if is_chat then
+ if DBReadSetting(hContact,Proto,uid,@ldbv)=0 then
begin
- if IsChat(hContact) then
+ if dbv._type=ldbv._type then
begin
- pw:=DBReadUnicode(hContact,Proto,'ChatRoomID');
- if StrCmpW(pw,dbv.szVal.W)=0 then result:=hContact;
- mFreeMem(pw);
- end
- end
- else
- begin
- if DBReadSetting(hContact,Proto,uid,@ldbv)=0 then
- begin
- if dbv._type=ldbv._type then
- begin
- case dbv._type of
-// DBVT_DELETED: ;
- DBVT_BYTE : if dbv.bVal=ldbv.bVal then result:=hContact;
- DBVT_WORD : if dbv.wVal=ldbv.wVal then result:=hContact;
- DBVT_DWORD : if dbv.dVal=ldbv.dVal then result:=hContact;
- DBVT_UTF8,
- DBVT_ASCIIZ : if StrCmp (dbv.szVal.A,ldbv.szVal.A)=0 then result:=hContact;
- DBVT_WCHAR : if StrCmpW(dbv.szVal.W,ldbv.szVal.W)=0 then result:=hContact;
- DBVT_BLOB : begin
- if dbv.cpbVal = ldbv.cpbVal then
- begin
- if CompareMem(dbv.pbVal,ldbv.pbVal,dbv.cpbVal) then
- result:=hContact;
- end;
+ case dbv._type of
+// DBVT_DELETED: ;
+ DBVT_BYTE : if dbv.bVal=ldbv.bVal then result:=hContact;
+ DBVT_WORD : if dbv.wVal=ldbv.wVal then result:=hContact;
+ DBVT_DWORD : if dbv.dVal=ldbv.dVal then result:=hContact;
+ DBVT_UTF8,
+ DBVT_ASCIIZ : if StrCmp (dbv.szVal.A,ldbv.szVal.A)=0 then result:=hContact;
+ DBVT_WCHAR : if StrCmpW(dbv.szVal.W,ldbv.szVal.W)=0 then result:=hContact;
+ DBVT_BLOB : begin
+ if dbv.cpbVal = ldbv.cpbVal then
+ begin
+ if CompareMem(dbv.pbVal,ldbv.pbVal,dbv.cpbVal) then
+ result:=hContact;
end;
end;
end;
- db_free(@ldbv);
end;
+ db_free(@ldbv);
end;
// added 2011.04.20
if result<>0 then break;
@@ -217,25 +205,14 @@ begin
if Proto<>nil then
begin
p:=StrCopyE(section,setting);
- is_chat:=IsChat(hContact);
- if is_chat then
- begin
- pw:=DBReadUnicode(hContact,Proto,'ChatRoomID');
- StrCopy(p,opt_cuid); DBWriteUnicode(0,group,section,pw);
- mFreeMem(pw);
- result:=1;
- end
- else
+ uid:=Proto_GetUniqueId(Proto);
+ if uid<>nil then
begin
- uid:=Proto_GetUniqueId(Proto);
- if uid<>nil then
+ if DBReadSetting(hContact,Proto,uid,@cws)=0 then
begin
- if DBReadSetting(hContact,Proto,uid,@cws)=0 then
- begin
- StrCopy(p,opt_cuid); DBWriteSetting(0,group,section,@cws);
- db_free(@cws);
- result:=1;
- end;
+ StrCopy(p,opt_cuid); DBWriteSetting(0,group,section,@cws);
+ db_free(@cws);
+ result:=1;
end;
end;
if result<>0 then
@@ -373,37 +350,28 @@ begin
begin
if acc=nil then
acc:=Proto_GetBaseAccountName(hContact);
- if IsChat(hContact) then
- begin
- p:=DBReadUnicode(hContact,acc,'ChatRoomID');
- StrReplaceW(buf,'%uid%',p);
- mFreeMem(p);
- end
- else
+ uid:=Proto_GetUniqueId(acc);
+ if uid<>nil then
begin
- uid:=Proto_GetUniqueId(acc);
- if uid<>nil then
+ if DBReadSetting(hContact,acc,uid,@ldbv)=0 then
begin
- if DBReadSetting(hContact,acc,uid,@ldbv)=0 then
- begin
- case ldbv._type of
- DBVT_DELETED: p:='[deleted]';
- DBVT_BYTE : p:=IntToStr(buf1,ldbv.bVal);
- DBVT_WORD : p:=IntToStr(buf1,ldbv.wVal);
- DBVT_DWORD : p:=IntToStr(buf1,ldbv.dVal);
- DBVT_UTF8 : UTF8ToWide(ldbv.szVal.A,p);
- DBVT_ASCIIZ : AnsiToWide(ldbv.szVal.A,p,Langpack_GetDefaultCodePage);
- DBVT_WCHAR : p:=ldbv.szVal.W;
- DBVT_BLOB : p:='blob';
- end;
- StrReplaceW(buf,'%uid%',p);
- if ldbv._type in [DBVT_UTF8,DBVT_ASCIIZ] then
- mFreeMem(p);
- db_free(@ldbv);
+ case ldbv._type of
+ DBVT_DELETED: p:='[deleted]';
+ DBVT_BYTE : p:=IntToStr(buf1,ldbv.bVal);
+ DBVT_WORD : p:=IntToStr(buf1,ldbv.wVal);
+ DBVT_DWORD : p:=IntToStr(buf1,ldbv.dVal);
+ DBVT_UTF8 : UTF8ToWide(ldbv.szVal.A,p);
+ DBVT_ASCIIZ : AnsiToWide(ldbv.szVal.A,p,Langpack_GetDefaultCodePage);
+ DBVT_WCHAR : p:=ldbv.szVal.W;
+ DBVT_BLOB : p:='blob';
end;
+ StrReplaceW(buf,'%uid%',p);
+ if ldbv._type in [DBVT_UTF8,DBVT_ASCIIZ] then
+ mFreeMem(p);
+ db_free(@ldbv);
end;
- StrReplaceW(buf,'%uid%',nil);
end;
+ StrReplaceW(buf,'%uid%',nil);
end;
SendMessage(list,CB_SETITEMDATA,
diff --git a/plugins/Variables/src/contact.cpp b/plugins/Variables/src/contact.cpp
index bb6194aad9..5904a2cd23 100644
--- a/plugins/Variables/src/contact.cpp
+++ b/plugins/Variables/src/contact.cpp
@@ -153,15 +153,6 @@ wchar_t* getContactInfoT(uint8_t type, MCONTACT hContact)
if ((res = Clist_GetGroup(hContact)) != nullptr)
return res;
break;
-
- case CNF_UNIQUEID:
- // UID for ChatRoom
- if (Contact::IsGroupChat(hContact, szProto))
- if ((res = db_get_wsa(hContact, szProto, "ChatRoomID")) != nullptr)
- return res;
-
- // UID for other contact
- break;
}
return Contact::GetInfo(type, hContact);