summaryrefslogtreecommitdiff
path: root/protocols/Tlen/tlen_czaty/src/ChatEvent.cpp
diff options
context:
space:
mode:
authorSzymon Tokarz <wsx22@o2.pl>2012-10-17 21:05:02 +0000
committerSzymon Tokarz <wsx22@o2.pl>2012-10-17 21:05:02 +0000
commitfd67a89688262e4e58337c33728488f5f29196a8 (patch)
treeb6f8d04257ce002aaf251d586d27253db3755c42 /protocols/Tlen/tlen_czaty/src/ChatEvent.cpp
parent1099f914b0eb16acdcbf594ac4105224a6dfb2fd (diff)
Tlen protocol adopted
- code moved to trunk\protocols folder - update project files (based on rev: 27, 228, 204, 350, 279, 280, 1374, 278) - changed code organisation to c++ convention (based on rev: 1092, 503, 504) - changed code to Miranda NG convention (based on rev: 49, 54, 312, 401, 321, 358, 410, 441, 477, 483, 496, 507, 515, 644, 652, 743, 956, 1206, 667, 1040, 1590, 1857) - folders restructurization (based on rev: 1890) - code cleaning (based on rev: 270, 398, 409) - this commit includes adopted sources of tlen_czaty.dll (former mucc.dll) plugin witch is now deprecated and will be removed -- wsx22{at}o2.pl git-svn-id: http://svn.miranda-ng.org/main/trunk@1972 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'protocols/Tlen/tlen_czaty/src/ChatEvent.cpp')
-rw-r--r--protocols/Tlen/tlen_czaty/src/ChatEvent.cpp174
1 files changed, 174 insertions, 0 deletions
diff --git a/protocols/Tlen/tlen_czaty/src/ChatEvent.cpp b/protocols/Tlen/tlen_czaty/src/ChatEvent.cpp
new file mode 100644
index 0000000000..98da308382
--- /dev/null
+++ b/protocols/Tlen/tlen_czaty/src/ChatEvent.cpp
@@ -0,0 +1,174 @@
+/*
+
+MUCC Group Chat GUI Plugin for Miranda NG
+Copyright (C) 2004 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 "ChatEvent.h"
+#include "Options.h"
+#include "Utils.h"
+#include <string.h>
+
+ChatEvent::ChatEvent() {
+
+ next = prev = NULL;
+ event.cbSize = sizeof(MUCCEVENT);
+ event.iType = 0;
+ event.pszID = NULL;
+ event.pszModule = NULL;
+ event.pszName = NULL;
+ event.pszNick = NULL;
+ event.pszText = NULL;
+ event.pszUID = NULL;
+}
+
+ChatEvent::ChatEvent(const MUCCEVENT *e) {
+
+ event.cbSize = sizeof(MUCCEVENT);
+ event.iType = e->iType;
+ event.bIsMe = e->bIsMe;
+ event.color = e->color;
+ event.dwData = e->dwData;
+ event.dwFlags = e->dwFlags;
+ event.iFont = e->iFont;
+ event.iFontSize = e->iFontSize;
+ event.time = e->time;
+ event.pszID = NULL;
+ event.pszModule = NULL;
+ event.pszName = NULL;
+ event.pszNick = NULL;
+ event.pszText = NULL;
+ event.pszUID = NULL;
+// Utils::copyString((char **)&(event.pszID), e->pszID);
+// Utils::copyString((char **)&(event.pszModule), e->pszModule);
+// Utils::copyString((char **)&(event.pszName), e->pszName);
+ if (e->iType == MUCC_EVENT_STATUS || e->iType == MUCC_EVENT_MESSAGE) {
+ Utils::copyString((char **)&(event.pszNick), e->pszNick);
+ }
+ if (e->iType == MUCC_EVENT_ERROR || e->iType == MUCC_EVENT_MESSAGE || e->iType == MUCC_EVENT_TOPIC) {
+ Utils::copyString((char **)&(event.pszText), e->pszText);
+ }
+// Utils::copyString((char **)&(event.pszUID), e->pszUID);
+ next = prev = NULL;
+}
+
+ChatEvent::~ChatEvent() {
+
+ if (event.pszID != NULL) {
+ delete (char *)event.pszID;
+ }
+ if (event.pszModule != NULL) {
+ delete (char *)event.pszModule;
+ }
+ if (event.pszName != NULL) {
+ delete (char *)event.pszName;
+ }
+ if (event.pszNick != NULL) {
+ delete (char *)event.pszNick;
+ }
+ if (event.pszText != NULL) {
+ delete (char *)event.pszText;
+ }
+ if (event.pszUID != NULL) {
+ delete (char *)event.pszUID;
+ }
+ if (next != NULL) {
+ next->setPrev(prev);
+ }
+ if (prev != NULL) {
+ prev->setNext(next);
+ }
+}
+
+ChatEvent * ChatEvent::getNext() {
+ return next;
+}
+
+ChatEvent * ChatEvent::getPrev() {
+ return prev;
+}
+
+void ChatEvent::setNext(ChatEvent *next) {
+ this->next = next;
+}
+
+void ChatEvent::setPrev(ChatEvent * prev) {
+ this->prev = prev;
+}
+
+const MUCCEVENT * ChatEvent::getEvent() {
+ return &event;
+}
+
+ChatEventList::ChatEventList() {
+ eventListEnd = &eventListRoot;
+ setMaxSize(DEFAULT_MAX_SIZE);
+ currentSize = 0;
+}
+
+ChatEventList::~ChatEventList() {
+ while (eventListRoot.getNext() != NULL) {
+ delete eventListRoot.getNext();
+ }
+}
+
+int ChatEventList::addEvent(const MUCCEVENT *muccevent) {
+ int trimmed = 0;
+ ChatEvent *event = new ChatEvent(muccevent);
+ event->setPrev(eventListEnd);
+ eventListEnd->setNext(event);
+ eventListEnd=event;
+ currentSize++;
+ if (currentSize>hiMaxSize) {
+ while (currentSize>loMaxSize && eventListRoot.getNext() != NULL) {
+ delete eventListRoot.getNext();
+ currentSize--;
+ trimmed = 1;
+ }
+ }
+ return trimmed;
+}
+
+ChatEvent * ChatEventList::getEvents() {
+ return eventListRoot.getNext();
+}
+
+void ChatEventList::setMaxSize(int s) {
+ loMaxSize = s;
+ if (s>200) {
+ hiMaxSize = s + s/10;
+ } else {
+ hiMaxSize = s + 20;
+ }
+}
+
+void ChatEventList::clear() {
+ ChatEvent *event = eventListRoot.getNext();
+ eventListRoot.setNext(NULL);
+ eventListEnd = &eventListRoot;
+ currentSize = 0;
+ if (event != NULL) {
+ event->setPrev(NULL);
+ while (event->getNext() != NULL) {
+ delete event->getNext();
+ }
+ delete event;
+ }
+}
+
+