diff options
author | Kirill Volinsky <Mataes2007@gmail.com> | 2017-11-30 07:57:29 +0300 |
---|---|---|
committer | Kirill Volinsky <Mataes2007@gmail.com> | 2017-11-30 07:57:29 +0300 |
commit | 6532896923fdf6e3d3b341ce21153b913fcda3dc (patch) | |
tree | aeccfbfbb5d4995d146eb62fd61fa7e4207dfcb1 /protocols/Tlen/src/tlen_list.cpp | |
parent | cc3d5628fade322f81abad8715d3d2ab031bc8b6 (diff) |
Tlen moved to deprecated (#1050)
Diffstat (limited to 'protocols/Tlen/src/tlen_list.cpp')
-rw-r--r-- | protocols/Tlen/src/tlen_list.cpp | 292 |
1 files changed, 0 insertions, 292 deletions
diff --git a/protocols/Tlen/src/tlen_list.cpp b/protocols/Tlen/src/tlen_list.cpp deleted file mode 100644 index f7a141cea6..0000000000 --- a/protocols/Tlen/src/tlen_list.cpp +++ /dev/null @@ -1,292 +0,0 @@ -/*
-
-Jabber Protocol Plugin for Miranda IM
-Tlen Protocol Plugin for Miranda NG
-Copyright (C) 2002-2004 Santithorn Bunchua
-Copyright (C) 2004-2007 Piotr Piastucki
-
-This program is free software; you can redistribute it and/or
-modify it under the terms of the GNU General Public License
-as published by the Free Software Foundation; either version 2
-of the License, or (at your option) any later version.
-
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-GNU General Public License for more details.
-
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-*/
-
-#include "stdafx.h"
-#include "tlen_list.h"
-
-
-static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item);
-
-void TlenListInit(TlenProtocol *proto)
-{
- proto->lists = nullptr;
- proto->listsCount = 0;
-}
-
-void TlenListUninit(TlenProtocol *proto)
-{
- TlenListWipe(proto);
-}
-
-void TlenListWipe(TlenProtocol *proto)
-{
- int i;
-
- mir_cslock lck(proto->csLists);
- for (i=0; i<proto->listsCount; i++)
- TlenListFreeItemInternal(&(proto->lists[i]));
- if (proto->lists != nullptr) {
- mir_free(proto->lists);
- proto->lists = nullptr;
- }
- proto->listsCount=0;
-}
-
-void TlenListWipeSpecial(TlenProtocol *proto)
-{
- int i;
- mir_cslock lck(proto->csLists);
- for (i=0; i<proto->listsCount; i++) {
- if (proto->lists[i].list != LIST_FILE && proto->lists[i].list != LIST_VOICE) {
- TlenListFreeItemInternal(&(proto->lists[i]));
- proto->listsCount--;
- memmove(proto->lists+i, proto->lists+i+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-i));
- i--;
- }
- }
- proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount);
-}
-
-static void TlenListFreeItemInternal(TLEN_LIST_ITEM *item)
-{
- if (item == nullptr)
- return;
-
- if (item->jid) mir_free(item->jid);
- if (item->nick) mir_free(item->nick);
- if (item->statusMessage) mir_free(item->statusMessage);
- if (item->group) mir_free(item->group);
- if (item->messageEventIdStr) mir_free(item->messageEventIdStr);
-// if (item->type) mir_free(item->type);
- //if (item->ft) TlenFileFreeFt(item->ft); // No need to free (it is always free when exit from TlenFileServerThread())
- if (item->roomName) mir_free(item->roomName);
- if (item->version) mir_free(item->version);
- if (item->software) mir_free(item->software);
- if (item->system) mir_free(item->system);
- if (item->avatarHash) mir_free(item->avatarHash);
-
- if (item->protocolVersion) mir_free(item->protocolVersion);
- if (item->id2) mir_free(item->id2);
-}
-
-static char * GetItemId(TLEN_LIST list, const char *jid)
-{
- char *s, *p, *q;
- s = mir_strdup(jid);
- if (list != LIST_PICTURE) {
- _strlwr(s);
- // strip resouce name if any
- if ((p=strchr(s, '@')) != nullptr) {
- if ((q=strchr(p, '/')) != nullptr)
- *q = '\0';
- }
- }
- return s;
-}
-
-
-int TlenListExist(TlenProtocol *proto, TLEN_LIST list, const char *jid)
-{
- int i;
- size_t len;
- char *s, *p;
- s = GetItemId(list, jid);
- len = mir_strlen(s);
-
- mir_cslock lck(proto->csLists);
- for (i=0; i<proto->listsCount; i++)
- if (proto->lists[i].list == list) {
- p = proto->lists[i].jid;
- if (p && mir_strlen(p) >= len && (p[(int)len] == '\0' || p[(int)len] == '/') && !strncmp(p, s, len)) {
- mir_free(s);
- return i+1;
- }
- }
- mir_free(s);
- return 0;
-}
-
-TLEN_LIST_ITEM *TlenListAdd(TlenProtocol *proto, TLEN_LIST list, const char *jid)
-{
- char *s;
- TLEN_LIST_ITEM *item;
-
- mir_cslock lck(proto->csLists);
- if ((item=TlenListGetItemPtr(proto, list, jid)) != nullptr) {
- return item;
- }
-
- s = GetItemId(list, jid);
- proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*(proto->listsCount+1));
- item = &(proto->lists[proto->listsCount]);
- memset(item, 0, sizeof(TLEN_LIST_ITEM));
- item->list = list;
- item->jid = s;
- item->nick = nullptr;
- item->status = ID_STATUS_OFFLINE;
- item->statusMessage = nullptr;
- item->group = nullptr;
- item->messageEventIdStr = nullptr;
- item->wantComposingEvent = FALSE;
- item->isTyping = FALSE;
-// item->type = NULL;
- item->ft = nullptr;
- item->roomName = nullptr;
- item->version = nullptr;
- item->software = nullptr;
- item->system = nullptr;
- item->avatarHash = nullptr;
- item->avatarFormat = PA_FORMAT_UNKNOWN;
- item->newAvatarDownloading = FALSE;
- item->versionRequested = FALSE;
- item->infoRequested = FALSE;
- proto->listsCount++;
-
- return item;
-}
-
-void TlenListRemove(TlenProtocol *proto, TLEN_LIST list, const char *jid)
-{
- int i;
-
- mir_cslock lck(proto->csLists);
- i = TlenListExist(proto, list, jid);
- if (!i) {
- return;
- }
- i--;
- TlenListFreeItemInternal(&(proto->lists[i]));
- proto->listsCount--;
- memmove(proto->lists+i, proto->lists+i+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-i));
- proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount);
-}
-
-void TlenListRemoveList(TlenProtocol *proto, TLEN_LIST list)
-{
- int i;
-
- i = 0;
- while ((i=TlenListFindNext(proto, list, i)) >= 0) {
- TlenListRemoveByIndex(proto, i);
- }
-}
-
-void TlenListRemoveByIndex(TlenProtocol *proto, int index)
-{
- mir_cslock lck(proto->csLists);
- if (index >= 0 && index<proto->listsCount) {
- TlenListFreeItemInternal(&(proto->lists[index]));
- proto->listsCount--;
- memmove(proto->lists+index, proto->lists+index+1, sizeof(TLEN_LIST_ITEM)*(proto->listsCount-index));
- proto->lists = (TLEN_LIST_ITEM *) mir_realloc(proto->lists, sizeof(TLEN_LIST_ITEM)*proto->listsCount);
- }
-}
-
-void TlenListAddResource(TlenProtocol *proto, TLEN_LIST list, const char *jid, int, const char *statusMessage)
-{
- int i;
-
- mir_cslock lck(proto->csLists);
- i = TlenListExist(proto, list, jid);
- if (!i) {
- return;
- }
- i--;
-
- if (proto->lists[i].statusMessage != nullptr)
- mir_free(proto->lists[i].statusMessage);
- if (statusMessage)
- proto->lists[i].statusMessage = mir_strdup(statusMessage);
- else
- proto->lists[i].statusMessage = nullptr;
-}
-
-void TlenListRemoveResource(TlenProtocol *proto, TLEN_LIST list, const char *jid)
-{
- int i;
- mir_cslock lck(proto->csLists);
- i = TlenListExist(proto, list, jid);
- if (!i) {
- return;
- }
- i--;
-}
-
-int TlenListFindNext(TlenProtocol *proto, TLEN_LIST list, int fromOffset)
-{
- int i;
-
- mir_cslock lck(proto->csLists);
- i = (fromOffset >= 0) ? fromOffset : 0;
- for (; i<proto->listsCount; i++)
- if (proto->lists[i].list == list) {
- return i;
- }
- return -1;
-}
-
-TLEN_LIST_ITEM *TlenListGetItemPtr(TlenProtocol *proto, TLEN_LIST list, const char *jid)
-{
- int i;
-
- mir_cslock lck(proto->csLists);
- i = TlenListExist(proto, list, jid);
- if (!i) {
- return nullptr;
- }
- i--;
- return &(proto->lists[i]);
-}
-
-TLEN_LIST_ITEM *TlenListFindItemPtrById2(TlenProtocol *proto, TLEN_LIST list, const char *id)
-{
-
- int i;
- size_t len;
- char *p;
-
- len = mir_strlen(id);
-
- mir_cslock lck(proto->csLists);
- for (i=0; i<proto->listsCount; i++) {
- if (proto->lists[i].list == list) {
- p = proto->lists[i].id2;
- if (p != nullptr) {
- if (!strncmp(p, id, len)) {
- return &(proto->lists[i]);
- }
- }
- }
- }
- return nullptr;
-}
-
-TLEN_LIST_ITEM *TlenListGetItemPtrFromIndex(TlenProtocol *proto, int index)
-{
- mir_cslock lck(proto->csLists);
- if (index >= 0 && index<proto->listsCount) {
- return &(proto->lists[index]);
- }
- return nullptr;
-}
-
|