aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/kvilib/core/kvi_list.h1035
-rw-r--r--src/kvirc/kvs/kvi_kvs_coresimplecommands.cpp1
-rw-r--r--src/kvirc/kvs/kvi_kvs_coresimplecommands.h1
-rw-r--r--src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp76
-rw-r--r--src/kvirc/kvs/kvi_kvs_timermanager.h10
-rw-r--r--src/kvirc/kvs/kvi_kvs_variant.cpp44
-rw-r--r--src/kvirc/kvs/kvi_kvs_variant.h2
-rw-r--r--src/kvirc/ui/kvi_console.cpp2
-rw-r--r--src/modules/context/libkvicontext.cpp113
-rwxr-xr-xsrc/modules/help/index.cpp20
-rwxr-xr-xsrc/modules/help/index.h11
-rw-r--r--src/modules/list/listwindow.cpp3
-rw-r--r--src/modules/logview/logviewmdiwindow.cpp2
-rw-r--r--src/modules/my/libkvimy.cpp4
-rw-r--r--src/modules/notifier/notifierwindowtabs.cpp24
-rw-r--r--src/modules/notifier/notifierwindowtabs.h12
-rw-r--r--src/modules/objects/class_list.cpp10
-rw-r--r--src/modules/url/libkviurl.cpp11
18 files changed, 1267 insertions, 114 deletions
diff --git a/src/kvilib/core/kvi_list.h b/src/kvilib/core/kvi_list.h
index 067fd7988..28345d49d 100644
--- a/src/kvilib/core/kvi_list.h
+++ b/src/kvilib/core/kvi_list.h
@@ -23,29 +23,1030 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
//=================================================================================================
+//=============================================================================
+//
+// C++ Template based double linked pointer list class
+// Original ss_list.h Created on 10 Dec 2001
+// Copyright (C) 2001-2007 Szymon Stefanek (pragma at kvirc dot net)
+// Added to KVIrc on 02 Jan 2008.
+//
+//=============================================================================
+// Qt changes the collection classes too much and too frequently.
+// I think we need to be independent of that to the maximum degree possible.
+// That's why we have our own fast pointer list class.
+// This does not depend on Qt AT ALL and has an interface similar
+// to the Qt<=3.x series. The pointer lists with the autodelete
+// feature was great and I don't completly understand why they have
+// been removed from Qt4 in favor of the value based non-autodeleting
+// lists... anyway: here we go :)
#include "kvi_settings.h"
-#ifdef COMPILE_USE_QT4
- #include <q3ptrlist.h>
- #define KviPtrList Q3PtrList
- #define KviPtrListBase Q3PtrList
- #define KviPtrListIterator Q3PtrListIterator
-#else
- #if QT_VERSION >= 300
- #include <qptrlist.h>
- #define KviPtrList QPtrList
- #define KviPtrListBase QPtrList
- #define KviPtrListIterator QPtrListIterator
- #else
- #include <qlist.h>
- #define KviPtrList QList
- #define KviPtrListBase QList
- #define KviPtrListIterator QListIterator
- #endif
+template<typename T> class KviPtrList;
+template<typename T> class KviPtrListIterator;
+
+#ifndef NULL
+ #define NULL 0
#endif
+///
+/// \internal
+///
+class KviPtrListNode
+{
+public:
+ KviPtrListNode * m_pPrev;
+ void * m_pData;
+ KviPtrListNode * m_pNext;
+};
+
+///
+/// \class KviPtrListIterator
+/// \brief A fast KviPtrList iterator.
+///
+/// This class allows traversing the list sequentially.
+/// Multilpe iterators can traverse the list at the same time.
+///
+/// Iteration example 1:
+///
+/// \verbatim
+/// KviPtrListIterator<T> it(list);
+/// for(bool b = it.moveFirst();b;b = it.moveNext())
+/// {
+/// T * pData = it.data();
+/// doSomethingWithData(pData);
+/// }
+/// \endverbatim
+///
+/// Iteration example 2:
+///
+/// \verbatim
+/// KviPtrListIterator<T> it(list);
+/// if(it.moveFirst())
+/// {
+/// do {
+/// T * pData = it.data();
+/// doSomethingWithData(pData);
+/// } while(it.moveNext());
+/// }
+/// \endverbatim
+///
+/// Iteration example 3:
+///
+/// \verbatim
+/// KviPtrListIterator<T> it(list.iteratorAt(10));
+/// if(it.isValid())
+/// {
+/// do {
+/// T * pData = it.data();
+/// doSomethingWithData(pData);
+/// while(it.movePrev());
+/// }
+/// \endverbatim
+///
+/// Please note that you must NOT remove any item from
+/// the list when using the iterators. An iterator pointing
+/// to a removed item will crash your application if you use it.
+/// The following code will NOT work (and crash):
+///
+/// \verbatim
+/// KviPtrList<T> l;
+/// l.append(new KviStr("x"));
+/// l.append(new KviStr("y"));
+/// KviPtrListIterator<T> it(l);
+/// it.moveFirst();
+/// l.removeFirst();
+/// KviStr * tmp = it.data(); <-- this will crash
+/// \endverbatim
+///
+/// In the rare cases in that you need to remove items
+/// while traversing the list you should put them
+/// in a temporary list and remove them after the iteration.
+///
+/// I've choosen this way because usually you don't modify
+/// the list while traversing it and a fix for this
+/// would add a constant overhead to several list operation.
+/// You just must take care of it yourself.
+///
+/// \warning This class is not thread safe by itself.
+///
+template<typename T> class KviPtrListIterator
+{
+protected:
+ KviPtrList<T> * m_pList;
+ KviPtrListNode * m_pNode;
+public:
+ ///
+ /// Creates an iterator copy.
+ /// The new iterator points exactly to the item pointed by src.
+ ///
+ KviPtrListIterator(const KviPtrListIterator<T> &src)
+ {
+ m_pList = src.m_pList;
+ m_pNode = src.m_pNode;
+ }
+
+ ///
+ /// Creates an iterator for the list l.
+ /// The iterator points to the first list item, if any.
+ ///
+ KviPtrListIterator(KviPtrList<T> &l)
+ {
+ m_pList = (KviPtrList<T> *)&l;
+ m_pNode = m_pList->m_pHead;
+ }
+
+ ///
+ /// Creates an iterator for the list l.
+ /// The iterator points to the specified list node.
+ ///
+ KviPtrListIterator(KviPtrList<T> &l,KviPtrListNode * pNode)
+ {
+ m_pList = (KviPtrList<T> *)&l;
+ m_pNode = pNode;
+ }
+
+ ///
+ /// Creates an iterator copy.
+ /// The new iterator points exactly to the item pointed by src.
+ ///
+ void operator = (const KviPtrListIterator<T> &src)
+ {
+ m_pList = src.m_pList;
+ m_pNode = src.m_pNode;
+ }
+public:
+ ///
+ /// Moves the iterator to the first element of the list.
+ /// Returns true in case of success or false if the list is empty.
+ ///
+ bool moveFirst()
+ {
+ m_pNode = m_pList->m_pHead;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Moves the iterator to the last element of the list.
+ /// Returns true in case of success or false if the list is empty.
+ ///
+ bool moveLast()
+ {
+ m_pNode = m_pList->m_pTail;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Moves the iterator to the next element of the list.
+ /// The iterator must be actually valid for this function to work.
+ /// Returns true in case of success or false if there is no next item.
+ ///
+ bool moveNext()
+ {
+ if(!m_pNode)return false;
+ m_pNode = m_pNode->m_pNext;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Moves the iterator to the next element of the list.
+ /// The iterator must be actually valid for this operator to work.
+ /// Returns true in case of success or false if there is no next item.
+ /// This is just a convenient alias to moveNext().
+ ///
+ bool operator ++()
+ {
+ if(!m_pNode)return false;
+ m_pNode = m_pNode->m_pNext;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Moves the iterator to the previous element of the list.
+ /// The iterator must be actually valid for this function to work.
+ /// Returns true in case of success or false if there is no previous item.
+ ///
+ bool movePrev()
+ {
+ if(!m_pNode)return false;
+ m_pNode = m_pNode->m_pPrev;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Moves the iterator to the previous element of the list.
+ /// The iterator must be actually valid for this operator to work.
+ /// Returns true in case of success or false if there is no previous item.
+ /// This is just a convenient alias to movePrev().
+ ///
+ bool operator --()
+ {
+ if(!m_pNode)return false;
+ m_pNode = m_pNode->m_pPrev;
+ return m_pNode != NULL;
+ }
+
+ ///
+ /// Returs the value pointed by the iterator
+ /// or NULL if the iterator is not valid.
+ ///
+ T * current()
+ {
+ return m_pNode ? (T *)(m_pNode->m_pData) : NULL;
+ }
+
+ ///
+ /// Returs the value pointed by the iterator
+ /// or NULL if the iterator is not valid.
+ /// This is just an alias to current().
+ ///
+ T * operator *()
+ {
+ return m_pNode ? (T *)(m_pNode->m_pData) : NULL;
+ }
+
+ ///
+ /// Returns true if this iterator points to a valid
+ /// element of the list and false otherwise.
+ ///
+ bool isValid()
+ {
+ return m_pNode != NULL;
+ }
+};
+
+///
+/// \class KviPtrList
+/// \brief A template double linked list of pointers.
+///
+/// The main advantage of this type of list is speed.
+/// Insertion of pointers is very fast when compared
+/// to the typical "copy constructor" call used
+/// in the "plain type" template list implementations.
+///
+/// Iterating over pointers is also very fast and this
+/// class contains an internal iterator that allows to
+/// write loops in a compact and clean way.
+/// See the first(), next(), current() and findRef()
+/// functions for the description of this feature.
+///
+/// There is also a non-const external iterator
+/// that you can use to traverse the list concurrently.
+/// There is no const iterator (and no const access methods)
+/// since the list provides the autoDelete() method
+/// which vould implicitly violate constness.
+/// If you have to deal with const objects then
+/// you need to use a QList instead.
+///
+/// Your objects also do not need to support copy constructors
+/// or >= operators. This class will work fine without them
+/// as opposed to a plain QList.
+///
+/// This class also supports automatic deletion of the inseted items.
+/// See the setAutoDelete() and autoDelete() members for the
+/// description of the feature.
+///
+/// Typcal usage:
+///
+/// \verbatim
+/// KviPtrList<MyClass> list();
+/// list.append(new MyClass());
+/// list.append(new MyClass());
+/// ...
+/// for(MyClass * c = list.first();c;c = list.next())doSomethingWith(c);
+/// delete list; // autodelete is set to true in the constructor
+/// \endverbatim
+///
+/// \warning This class is absolutely NOT thread safe. You must
+/// protect concurrent access from multiple threads by
+/// using an external synchronization tool (such as KviMutex).
+///
+template<typename T> class KviPtrList
+{
+ friend class KviPtrListIterator<T>;
+protected:
+ bool m_bAutoDelete; //< do we automatically delete items when they are removed ?
+
+ KviPtrListNode * m_pHead; //< our list head pointer (NULL if there are no items in the list)
+ KviPtrListNode * m_pTail; //< our list tail
+ KviPtrListNode * m_pAux; //< our iteration pointer
+
+ unsigned int m_uCount; //< the count of items in the list
+protected:
+ ///
+ /// \internal
+ ///
+ /// inserts the item d before the item ref or at the beginning
+ /// if ref is not found in the list
+ /// also sets the current iteration pointer to the newly inserted item
+ ///
+ void insertBeforeSafe(KviPtrListNode * ref,const T * d)
+ {
+ m_pAux = ref;
+ KviPtrListNode * n = new KviPtrListNode;
+ n->m_pPrev = m_pAux->m_pPrev;
+ n->m_pNext = m_pAux;
+ if(m_pAux->m_pPrev)
+ {
+ m_pAux->m_pPrev->m_pNext = n;
+ } else {
+ m_pHead = n;
+ }
+ m_pAux->m_pPrev = n;
+ n->m_pData = (void *)d;
+ m_uCount++;
+ }
+
+ ///
+ /// \internal
+ ///
+ /// Grabs the first element from the list src
+ /// and puts it as the first element of this list.
+ ///
+ void grabFirstAndPrepend(KviPtrList<T> * src)
+ {
+ KviPtrListNode * pNewHead = src->m_pHead;
+ if(!pNewHead)
+ return;
+
+ if(pNewHead->m_pNext)
+ {
+ src->m_pHead = pNewHead->m_pNext;
+ src->m_pHead->m_pPrev = NULL;
+ } else {
+ src->m_pHead = NULL;
+ src->m_pTail = NULL;
+ }
+
+ if(m_pHead)
+ {
+ m_pHead->m_pPrev = pNewHead;
+ pNewHead->m_pNext = m_pHead;
+ m_pHead = pNewHead;
+ } else {
+ m_pHead = pNewHead;
+ m_pTail = pNewHead;
+ m_pHead->m_pNext = NULL;
+ }
+ m_uCount++;
+ src->m_uCount--;
+ }
+
+ ///
+ /// \internal
+ ///
+ /// Removes the current iteration item assuming that it is valid.
+ ///
+ void removeCurrentSafe()
+ {
+ if(m_pAux->m_pPrev)
+ m_pAux->m_pPrev->m_pNext = m_pAux->m_pNext;
+ else
+ m_pHead = m_pAux->m_pNext;
+ if(m_pAux->m_pNext)
+ m_pAux->m_pNext->m_pPrev = m_pAux->m_pPrev;
+ else
+ m_pTail = m_pAux->m_pPrev;
+ if(m_bAutoDelete)
+ delete ((const T *)(m_pAux->m_pData));
+ delete m_pAux;
+ m_pAux = NULL;
+ m_uCount--;
+ }
+
+public:
+ ///
+ /// Inserts the list src inside this list
+ /// by respecting the sort order.
+ /// The src list elements are removed.
+ ///
+ void merge(KviPtrList<T> * src)
+ {
+ m_pAux = m_pHead;
+ KviPtrListNode * n = src->m_pHead;
+ m_uCount += src->m_uCount;
+ while(m_pAux && n)
+ {
+ if(kvi_compare((const T *)(m_pAux->m_pData),(const T *)(n->m_pData)) > 0)
+ {
+ // our element is greater, n->m_pData goes first
+ KviPtrListNode * pNext = n->m_pNext;
+ n->m_pPrev = m_pAux->m_pPrev; // his prev becomes
+ n->m_pNext = m_pAux;
+ if(m_pAux->m_pPrev)
+ m_pAux->m_pPrev->m_pNext = n;
+ else
+ m_pHead = n;
+ m_pAux->m_pPrev = n;
+ n = pNext;
+ } else {
+ // that element is greater
+ m_pAux = m_pAux->m_pNext;
+ }
+ }
+ if(n)
+ {
+ // last items to append
+ if(m_pTail)
+ {
+ m_pTail->m_pNext = n;
+ n->m_pPrev = m_pTail;
+ } else {
+ m_pHead = n;
+ m_pTail = n;
+ n->m_pPrev = NULL;
+ }
+ m_pTail = src->m_pTail;
+ }
+
+ src->m_pHead = NULL;
+ src->m_pTail = NULL;
+ src->m_uCount = 0;
+ }
+
+ void swap(KviPtrList<T> * src)
+ {
+ KviPtrListNode * n = m_pHead;
+ m_pHead = src->m_pHead;
+ src->m_pHead = n;
+ n = m_pTail;
+ m_pTail = src->m_pTail;
+ src->m_pTail = n;
+ unsigned int uCount = m_uCount;
+ m_uCount = src->m_uCount;
+ src->m_uCount = uCount;
+ }
+
+
+ ///
+ /// Sorts this list in ascending order.
+ /// There must be an int kvi_compare(const T *p1,const T *p2) function
+ /// which returns a value less than, equal to
+ /// or greater than zero when the item p1 is considered lower than,
+ /// equal to or greater than p2.
+ ///
+ void sort()
+ {
+ if(m_uCount < 2)return;
+
+ KviPtrList<T> carry;
+ KviPtrList<T> tmp[64];
+ KviPtrList * fill = &tmp[0];
+ KviPtrList * counter;
+
+ do {
+ carry.grabFirstAndPrepend(this);
+
+ for(counter = &tmp[0];counter != fill && !counter->isEmpty();++counter)
+ {
+ counter->merge(&carry);
+ carry.swap(counter);
+ }
+ carry.swap(counter);
+ if(counter == fill)
+ ++fill;
+ } while(m_uCount > 0);
+
+ for(counter = &tmp[1];counter != fill;++counter)
+ counter->merge(counter-1);
+ swap(fill-1);
+ }
+
+ ///
+ /// Inserts the item respecting the sorting order inside the list.
+ /// The list itself must be already sorted for this to work correctly.
+ /// There must be a int kvi_compare(const T *p1,const T * p2)
+ /// that returns a value less than, equal to
+ /// or greater than zero when the item p1 is considered lower than,
+ /// equal to or greater than p2.
+ ///
+ void inSort(T * t)
+ {
+ KviPtrListNode * x = m_pHead;
+ while(x && (kvi_compare(((T *)x->m_pData),t) > 0))x = x->m_pNext;
+ if(!x)append(t);
+ else insertBeforeSafe(x,t);
+ }
+
+ ///
+ /// Returns true if the list is empty
+ ///
+ bool isEmpty() const
+ {
+ return (m_pHead == NULL);
+ }
+
+ ///
+ /// Returns the count of the items in the list
+ ///
+ unsigned int count() const
+ {
+ return m_uCount;
+ }
+
+ ///
+ /// Sets the iteration pointer to the first item in the list
+ /// and returns that item (or 0 if the list is empty)
+ ///
+ T * first()
+ {
+ if(!m_pHead)return NULL;
+ m_pAux = m_pHead;
+ return (T *)(m_pAux->m_pData);
+ }
+
+ ///
+ /// Removes the first element from the list
+ /// and returns it to the caller. This function
+ /// obviously never deletes the item (regadless of autoDeletion()).
+ ///
+ T * takeFirst()
+ {
+ if(!m_pHead)return NULL;
+ T * pData = (T *)m_pHead->m_pData;
+ if(m_pHead->m_pNext)
+ {
+ m_pHead = m_pHead->m_pNext;
+ delete m_pHead->m_pPrev;
+ m_pHead->m_pPrev = NULL;
+ } else {
+ delete m_pHead;
+ m_pHead = NULL;
+ m_pTail = NULL;
+ }
+ m_uCount--;
+ return pData;
+ }
+
+ ///
+ /// Returns an iterator pointing to the first item of the list.
+ ///
+ KviPtrListIterator<T> iteratorAtFirst()
+ {
+ return KviPtrListIterator<T>(*this,m_pHead);
+ }
+
+ ///
+ /// Sets the iteration pointer to the last item in the list
+ /// and returns that item (or 0 if the list is empty)
+ ///
+ T * last()
+ {
+ if(!m_pTail)return NULL;
+ m_pAux = m_pTail;
+ return (T *)(m_pAux->m_pData);
+ }
+
+ ///
+ /// Returns an iterator pointing to the first item of the list.
+ ///
+ KviPtrListIterator<T> iteratorAtLast()
+ {
+ return KviPtrListIterator<T>(*this,m_pTail);
+ }
+
+ ///
+ /// Returns the current iteration item
+ /// A call to this function MUST be preceded by a call to
+ /// first(),last(),at() or findRef()
+ ///
+ T * current()
+ {
+ return (T *)(m_pAux->m_pData);
+ }
+
+ ///
+ /// Returns the current iteration item
+ /// A call to this function should be preceded by a call to
+ /// first(),last(),at() or findRef().
+ /// This function will return a NULL pointer if the current
+ /// item has been invalidated due to a remove operation.
+ ///
+ T * safeCurrent()
+ {
+ return m_pAux ? (T *)(m_pAux->m_pData) : NULL;
+ }
+
+
+ ///
+ /// Returns an iterator pointing to the current item in the list.
+ /// A call to this function MUST be preceded by a call to
+ /// first(),last(),at() or findRef()
+ ///
+ KviPtrListIterator<T> iteratorAtCurrent()
+ {
+ return KviPtrListIterator<T>(*this,m_pAux);
+ }
+
+ ///
+ /// Sets the iteration pointer to the next item in the list
+ /// and returns that item (or 0 if the end of the list has been reached)
+ /// A call to this function MUST be preceded by a call to
+ /// first(),last(),at() or findRef()
+ ///
+ T * next()
+ {
+ m_pAux = m_pAux->m_pNext;
+ if(m_pAux)return (T *)(m_pAux->m_pData);
+ return NULL;
+ }
+
+ ///
+ /// Sets the iteration pointer to the previous item in the list
+ /// and returns that item (or 0 if the beginning of the list has been reached)
+ /// A call to this function MUST be preceded by a call to
+ /// first(),last(),at() or findRef()
+ ///
+ T * prev()
+ {
+ m_pAux = m_pAux->m_pPrev;
+ if(m_pAux)return (T *)(m_pAux->m_pData);
+ return NULL;
+ }
+
+ ///
+ /// Sets the iteration pointer to the nTh item in the list
+ /// and returns that item (or 0 if the index is out of range)
+ ///
+ T * at(int idx)
+ {
+ T * t = first();
+ int cnt = 0;
+ while(t)
+ {
+ if(idx == cnt)return t;
+ t = next();
+ cnt++;
+ }
+ return 0;
+ }
+
+ ///
+ /// Returns an iterator pointing to the item at the specified index.
+ ///
+ KviPtrListIterator<T> iteratorAt(int idx)
+ {
+ KviPtrListNode * n = m_pHead;
+ int cnt = 0;
+ while(n)
+ {
+ if(idx == cnt)
+ return KviPtrListIterator<T>(*this,n);
+ n = n->m_pNext;
+ cnt++;
+ }
+ return KviPtrListIterator<T>(*this,NULL);
+ }
+
+ ///
+ /// Sets the iteration pointer to the item with pointer d
+ /// and returns its position (zero based index) in the list or -1 if the
+ /// item cannot be found
+ ///
+ int findRef(const T * d)
+ {
+ int ret = 0;
+ for(T * t = first();t;t = next())
+ {
+ if(t == d)return ret;
+ ret++;
+ }
+ return -1;
+ }
+
+ ///
+ /// Returns an iterator pointing to the item with pointer d.
+ ///
+ KviPtrListIterator<T> iteratorAtRef(const T * d)
+ {
+ KviPtrListNode * n = m_pHead;
+ while(n)
+ {
+ if(n->m_pData == d)
+ return KviPtrListIterator<T>(*this,n);
+ n = n->m_pNext;
+ }
+ return KviPtrListIterator<T>(*this,NULL);
+ }
+
+ ///
+ /// Appends an item at the end of the list
+ ///
+ void append(const T * d)
+ {
+ if(!m_pHead)
+ {
+ m_pHead = new KviPtrListNode;
+ m_pHead->m_pPrev = NULL;
+ m_pHead->m_pNext = NULL;
+ m_pHead->m_pData = (void *)d;
+ m_pTail = m_pHead;
+ } else {
+ m_pTail->m_pNext = new KviPtrListNode;
+ m_pTail->m_pNext->m_pPrev = m_pTail;
+ m_pTail->m_pNext->m_pNext = NULL;
+ m_pTail->m_pNext->m_pData = (void *)d;
+ m_pTail = m_pTail->m_pNext;
+ }
+ m_uCount++;
+ }
+
+ ///
+ /// Appends all the items from the list l to this list
+ ///
+ void append(KviPtrList<T> * l)
+ {
+ for(T * t = l->first();t;t = l->next())append(t);
+ }
+
+ ///
+ /// Prepends (inserts in head position) all the items from
+ /// the list l to this list
+ ///
+ void prepend(KviPtrList<T> * l)
+ {
+ for(T * t = l->last();t;t = l->prev())prepend(t);
+ }
+
+ ///
+ /// Inserts the item d in the head position
+ ///
+ void prepend(const T * d)
+ {
+ if(!m_pHead)
+ {
+ m_pHead = new KviPtrListNode;
+ m_pHead->m_pPrev = NULL;
+ m_pHead->m_pNext = NULL;
+ m_pHead->m_pData = (void *)d;
+ m_pTail = m_pHead;
+ } else {
+ m_pHead->m_pPrev = new KviPtrListNode;
+ m_pHead->m_pPrev->m_pNext = m_pHead;
+ m_pHead->m_pPrev->m_pPrev = NULL;
+ m_pHead->m_pPrev->m_pData = (void *)d;
+ m_pHead = m_pHead->m_pPrev;
+ m_uCount++;
+ }
+ }
+
+ ///
+ /// Inserts the item d at the zero-based position
+ /// specified by iIndex. If the specified position
+ /// is out of the list then the item is appended.
+ /// Note that this function costs O(n).
+ /// It's really better to use insertAfter() or
+ /// insertBefore(), if possible.
+ ///
+ void insert(int iIndex,const T * d)
+ {
+ m_pAux = m_pHead;
+ while(m_pAux && iIndex > 0)
+ {
+ iIndex--;
+ m_pAux = m_pAux->m_pNext;
+ }
+ if(m_pAux)
+ insertBeforeSafe(m_pAux,d);
+ else
+ append(d);
+ }
+
+ ///
+ /// Removes the firstitem (if any)
+ /// the item is deleted if autoDelete() is set to true
+ ///
+ bool removeFirst()
+ {
+ if(!m_pHead)return false;
+ if(m_pHead->m_pNext)
+ {
+ m_pHead = m_pHead->m_pNext;
+ if(m_bAutoDelete)
+ delete ((const T *)(m_pHead->m_pPrev->m_pData));
+ delete m_pHead->m_pPrev;
+ m_pHead->m_pPrev = NULL;
+ } else {
+ if(m_bAutoDelete)
+ delete ((const T *)(m_pHead->m_pData));
+ delete m_pHead;
+ m_pHead = NULL;
+ m_pTail = NULL;
+ }
+ m_pAux = NULL;
+ m_uCount--;
+ return true;
+ }
+
+ ///
+ /// Removes the firstitem (if any)
+ /// the item is deleted if autoDelete() is set to true
+ ///
+ bool removeLast()
+ {
+ if(!m_pTail)return false;
+ if(m_pTail->m_pPrev)
+ {
+ m_pTail = m_pTail->m_pPrev;
+ if(m_bAutoDelete)
+ delete ((const T *)(m_pTail->m_pNext->m_pData));
+ delete m_pTail->m_pNext;
+ m_pTail->m_pNext = NULL;
+ } else {
+ if(m_bAutoDelete)
+ delete ((const T *)(m_pTail->m_pData));
+ delete m_pTail;
+ m_pHead = NULL;
+ m_pTail = NULL;
+ }
+ m_pAux = NULL;
+ m_uCount--;
+ return true;
+ }
+
+ ///
+ /// Removes the item at zero-based position iIndex.
+ /// Does nothing and returns false if iIndex is out of the list.
+ /// Please note that this function costs O(n).
+ ///
+ bool remove(int iIndex)
+ {
+ m_pAux = m_pHead;
+ while(m_pAux && iIndex > 0)
+ {
+ iIndex--;
+ m_pAux = m_pAux->m_pNext;
+ }
+ if(!m_pAux)
+ return false;
+ removeCurrentSafe();
+ return true;
+ }
+
+ ///
+ /// Sets the autodelete flag
+ /// When this flag is on (default) , all the items
+ /// are deleted when removed from the list (or when the list is destroyed
+ /// or cleared explicitly)
+ ///
+ void setAutoDelete(bool bAutoDelete)
+ {
+ m_bAutoDelete = bAutoDelete;
+ }
+
+ ///
+ /// Returns the autodelete flag.
+ ///
+ bool autoDelete()
+ {
+ return m_bAutoDelete;
+ };
+
+ ///
+ /// Removes all the items from the list
+ /// (the items are deleted if the autoDelete() flag is set to true)
+ ///
+ void clear()
+ {
+ while(m_pHead)removeFirst();
+ }
+
+ ///
+ /// Removes the current iteration item.
+ /// Returns true if the current iteration item was valid (and was removed)
+ /// and false otherwise.
+ ///
+ bool removeCurrent()
+ {
+ if(!m_pAux)
+ return false;
+ removeCurrentSafe();
+ return true;
+ }
+
+ ///
+ /// Removes the item pointed by d (if found in the list)
+ /// the item is deleted if the autoDelete() flag is set to true)
+ /// Returns true if the item was in the list and false otherwise.
+ ///
+ bool removeRef(const T * d)
+ {
+ if(findRef(d) == -1)return false;
+ removeCurrentSafe();
+ return true;
+ }
+
+ ///
+ /// inserts the item d after the item ref or at the end
+ /// if ref is not found in the list
+ /// also sets the current iteration pointer to the newly inserted item
+ ///
+ void insertAfter(const T * ref,const T * d)
+ {
+ if(findRef(ref) == -1)
+ {
+ append(d);
+ return;
+ }
+ KviPtrListNode * n = new KviPtrListNode;
+ n->m_pPrev = m_pAux;
+ n->m_pNext = m_pAux->m_pNext;
+ if(m_pAux->m_pNext)
+ m_pAux->m_pNext->m_pPrev = n;
+ else
+ m_pTail = n;
+ m_pAux->m_pNext = n;
+ n->m_pData = (void *)d;
+ m_uCount++;
+ }
+
+ ///
+ /// inserts the item d before the item ref or at the beginning
+ /// if ref is not found in the list
+ /// also sets the current iteration pointer to the newly inserted item
+ ///
+ void insertBefore(const T * ref,const T * d)
+ {
+ if(findRef(ref) == -1)
+ {
+ prepend(d);
+ return;
+ }
+ KviPtrListNode * n = new KviPtrListNode;
+ n->m_pPrev = m_pAux->m_pPrev;
+ n->m_pNext = m_pAux;
+ if(m_pAux->m_pPrev)
+ m_pAux->m_pPrev->m_pNext = n;
+ else
+ m_pHead = n;
+ m_pAux->m_pPrev = n;
+ n->m_pData = (void *)d;
+ m_uCount++;
+ }
+
+ ///
+ /// Inverts the elements in the list.
+ ///
+ void invert()
+ {
+ if(!m_pHead)return;
+ KviPtrListNode * oldHead = m_pHead;
+ KviPtrListNode * oldTail = m_pTail;
+ KviPtrListNode * n = m_pHead;
+ while(n)
+ {
+ KviPtrListNode * next = n->m_pNext;
+ n->m_pNext = n->m_pPrev;
+ n->m_pPrev = next;
+ n = next;
+ }
+ m_pTail = oldHead;
+ m_pHead = oldTail;
+ }
+
+ ///
+ /// clears the list and inserts all the items from the list l
+ ///
+ void copyFrom(KviPtrList<T> * l)
+ {
+ clear();
+ for(T * t = l->first();t;t = l->next())append(t);
+ }
+
+ ///
+ /// equivalent to copyFrom(l)
+ ///
+ KviPtrList<T> & operator = (KviPtrList<T> &l)
+ {
+ copyFrom(&l);
+ return *this;
+ }
+
+ ///
+ /// creates a template list
+ ///
+ KviPtrList<T>(bool bAutoDelete = true)
+ {
+ m_bAutoDelete = bAutoDelete;
+ m_pHead = NULL;
+ m_pTail = NULL;
+ m_uCount = 0;
+ m_pAux = NULL;
+ };
+
+ ///
+ /// destroys the list
+ /// if autoDelete() is set to true, all the items are deleted
+ ///
+ virtual ~KviPtrList<T>()
+ {
+ clear();
+ };
+};
+
+#define KviPtrListBase KviPtrList
+
// BROKEN MSVC LINKER
#ifdef COMPILE_ON_WINDOWS
#include "kvi_string.h"
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands.cpp
index 68415bfea..04af2d858 100644
--- a/src/kvirc/kvs/kvi_kvs_coresimplecommands.cpp
+++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands.cpp
@@ -84,6 +84,7 @@ namespace KviKvsCoreSimpleCommands
_REGCMD("leave",part)
_REGCMD("links",rfc2812wrapper)
_REGCMD("list",rfc2812wrapper)
+ _REGCMD("listtimers",listtimers)
_REGCMD("lusers",rfc2812wrapper)
// m_r
_REGCMD("me",me)
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands.h b/src/kvirc/kvs/kvi_kvs_coresimplecommands.h
index a92d404ed..d218f37d5 100644
--- a/src/kvirc/kvs/kvi_kvs_coresimplecommands.h
+++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands.h
@@ -81,6 +81,7 @@ namespace KviKvsCoreSimpleCommands
KVSCSC(join);
KVSCSC(kick);
KVSCSC(killtimer);
+ KVSCSC(listtimers);
// m_r
KVSCSC(me);
KVSCSC(mode);
diff --git a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp
index 68bb4332b..b62bf0244 100644
--- a/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp
+++ b/src/kvirc/kvs/kvi_kvs_coresimplecommands_gl.cpp
@@ -35,6 +35,8 @@
#include "kvi_ircconnectionserverinfo.h"
#include "kvi_locale.h"
+#include "kvi_out.h"
+
#ifdef COMPILE_USE_QT4
#include <q3mimefactory.h>
#endif
@@ -506,12 +508,11 @@ try_again:
in this case the current timer will be scheduled for killing immediately
after it has returned control to KVIrc.
@seealso:
- [cmd]timer[/cmd], [fnc]$isTimer[/fnc]
+ [cmd]timer[/cmd], [fnc]$isTimer[/fnc], [cmd]listtimers[/cmd]
*/
KVSCSC(killtimer)
{
-#ifdef COMPILE_NEW_KVS
QString szName;
KVSCSC_PARAMETERS_BEGIN
KVSCSC_PARAMETER("name",KVS_PT_STRING,KVS_PF_OPTIONAL,szName)
@@ -537,7 +538,6 @@ try_again:
KVSCSC_pContext->warning(__tr2qs("Can't kill the timer '%Q' since it is not running"),&szName);
}
}
-#endif
return true;
}
@@ -599,6 +599,75 @@ try_again:
///////////////////////////////////////////////////////////////////////////////////////////////////////
/*
+ @doc: listtimers
+ @title:
+ listtimers
+ @type:
+ command
+ @short:
+ Lists the active timers
+ @syntax:
+ listtimers
+ @description:
+ Lists the currently active timers
+ @seealso:
+ [cmd]timer[/cmd], [fnc]$isTimer[/fnc], [cmd]killtimer[/cmd]
+ */
+
+ KVSCSC(listtimers)
+ {
+ KviDict<KviKvsTimer> * pTimerDict = KviKvsTimerManager::instance()->timerDict();
+
+ if(!pTimerDict)
+ return true;
+
+ KviDictIterator<KviKvsTimer> it(*pTimerDict);
+
+ KVSCSC_pContext->window()->outputNoFmt(KVI_OUT_VERBOSE,__tr2qs("List of active timers"));
+
+ unsigned int uCnt = 0;
+
+ while(KviKvsTimer * pTimer = it.current())
+ {
+ QString szName = pTimer->name();
+ QString szLifetime;
+ switch(pTimer->lifetime())
+ {
+ case KviKvsTimer::Persistent:
+ szLifetime = __tr2qs("Persistent");
+ break;
+ case KviKvsTimer::WindowLifetime:
+ szLifetime = __tr2qs("WindowLifetime");
+ break;
+ case KviKvsTimer::SingleShot:
+ szLifetime = __tr2qs("SingleShot");
+ break;
+ default:
+ szLifetime = __tr2qs("Unknown");
+ break;
+ }
+ QString szDelay;
+ szDelay.setNum(pTimer->delay());
+ QString szWindow;
+ szWindow = pTimer->window() ? pTimer->window()->id() : __tr2qs("None");
+
+ KVSCSC_pContext->window()->output(KVI_OUT_VERBOSE,
+ "Timer \"%Q\": Lifetime: %Q, Delay: %Q, Window: %Q",
+ &szName,&szLifetime,&szDelay,&szWindow
+ );
+
+ uCnt++;
+ ++it;
+ }
+
+ KVSCSC_pContext->window()->output(KVI_OUT_VERBOSE,__tr2qs("Total: %u timers running"),uCnt);
+
+ return true;
+ }
+
+ ///////////////////////////////////////////////////////////////////////////////////////////////////////
+
+ /*
@doc: lusers
@type:
command
@@ -619,5 +688,6 @@ try_again:
*/
// RFC2821 wrapper
+
};
diff --git a/src/kvirc/kvs/kvi_kvs_timermanager.h b/src/kvirc/kvs/kvi_kvs_timermanager.h
index f7d17348e..6b51c6514 100644
--- a/src/kvirc/kvs/kvi_kvs_timermanager.h
+++ b/src/kvirc/kvs/kvi_kvs_timermanager.h
@@ -94,10 +94,10 @@ protected: // it only can be created and destroyed by KviKvsTimerManager::init()
private:
KviIntDict<KviKvsTimer> * m_pTimerDictById; // stored by id
KviDict<KviKvsTimer> * m_pTimerDictByName; // stored by name
- static KviKvsTimerManager * m_pInstance; // the one and only timer manager instance
- KviPtrList<KviKvsTimer> * m_pKilledTimerList; // list of timers for that killing has been scheduled
- int m_iAssassinTimer; // assassin timer id
- int m_iCurrentTimer; // the timer currently executed
+ static KviKvsTimerManager * m_pInstance; // the one and only timer manager instance
+ KviPtrList<KviKvsTimer> * m_pKilledTimerList; // list of timers for that killing has been scheduled
+ int m_iAssassinTimer; // assassin timer id
+ int m_iCurrentTimer; // the timer currently executed
public:
static KviKvsTimerManager * instance(){ return m_pInstance; };
static void init();
@@ -112,6 +112,8 @@ public:
bool deleteCurrentTimer();
void deleteAllTimers();
bool timerExists(const QString &szName){ return m_pTimerDictByName->find(szName); };
+ KviDict<KviKvsTimer> * timerDict()
+ { return m_pTimerDictByName; };
protected:
void scheduleKill(KviKvsTimer * t);
virtual void timerEvent(QTimerEvent *e);
diff --git a/src/kvirc/kvs/kvi_kvs_variant.cpp b/src/kvirc/kvs/kvi_kvs_variant.cpp
index 0ec5030d3..9605ee262 100644
--- a/src/kvirc/kvs/kvi_kvs_variant.cpp
+++ b/src/kvirc/kvs/kvi_kvs_variant.cpp
@@ -738,7 +738,7 @@ bool KviKvsVariant::isEqualToNothing() const
class KviKvsVariantComparison
{
public:
- static inline int compare_integer_string(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_string(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.iInteger == 0)
{
@@ -757,49 +757,49 @@ public:
return -1 * KviQString::cmpCI(szString,*(v2->m_pData->m_u.pString));
}
- static inline int compare_integer_real(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_real(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(((kvs_real_t)v1->m_pData->m_u.iInteger) == *(v2->m_pData->m_u.pReal))return CMP_EQUAL;
if(((kvs_real_t)v1->m_pData->m_u.iInteger) > *(v2->m_pData->m_u.pReal))return CMP_THISGREATER;
return CMP_OTHERGREATER;
}
- static inline int compare_integer_boolean(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_boolean(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.iInteger == 0)
return v2->m_pData->m_u.bBoolean ? CMP_OTHERGREATER : CMP_EQUAL;
return v2->m_pData->m_u.bBoolean ? CMP_EQUAL : CMP_THISGREATER;
}
- static inline int compare_integer_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.iInteger == 0)
return v2->m_pData->m_u.pHash->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
return CMP_THISGREATER;
}
- static inline int compare_integer_array(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_array(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.iInteger == 0)
return v2->m_pData->m_u.pArray->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
return CMP_THISGREATER;
}
- static inline int compare_integer_hobject(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_integer_hobject(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.iInteger == 0.0)
return (v2->m_pData->m_u.hObject == (kvs_hobject_t)0) ? CMP_EQUAL : CMP_THISGREATER;
return CMP_OTHERGREATER;
}
- static inline int compare_real_hobject(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_real_hobject(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(*(v1->m_pData->m_u.pReal) == 0.0)
return (v2->m_pData->m_u.hObject == (kvs_hobject_t)0) ? CMP_EQUAL : CMP_THISGREATER;
return CMP_OTHERGREATER;
}
- static inline int compare_real_string(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_real_string(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(*(v1->m_pData->m_u.pReal) == 0.0)
{
@@ -818,28 +818,28 @@ public:
return -1 * KviQString::cmpCI(szString,*(v2->m_pData->m_u.pString));
}
- static inline int compare_real_boolean(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_real_boolean(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(*(v1->m_pData->m_u.pReal) == 0.0)
return v2->m_pData->m_u.bBoolean ? CMP_OTHERGREATER : CMP_EQUAL;
return v2->m_pData->m_u.bBoolean ? CMP_EQUAL : CMP_THISGREATER;
}
- static inline int compare_real_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_real_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(*(v1->m_pData->m_u.pReal) == 0)
return v2->m_pData->m_u.pHash->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
return CMP_THISGREATER;
}
- static inline int compare_real_array(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_real_array(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(*(v1->m_pData->m_u.pReal) == 0)
return v2->m_pData->m_u.pArray->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
return CMP_THISGREATER;
}
- static inline int compare_string_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_string_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.pString->isEmpty())
{
@@ -848,7 +848,7 @@ public:
return CMP_THISGREATER;
}
- static inline int compare_string_array(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_string_array(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.pString->isEmpty())
{
@@ -857,7 +857,7 @@ public:
return CMP_THISGREATER;
}
- static inline int compare_string_hobject(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_string_hobject(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v2->m_pData->m_u.hObject == (kvs_hobject_t)0)
{
@@ -873,7 +873,7 @@ public:
return CMP_THISGREATER;
}
- static inline int compare_boolean_string(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_boolean_string(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v2->isEqualToNothing())
{
@@ -883,7 +883,7 @@ public:
}
}
- static inline int compare_boolean_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_boolean_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.bBoolean)
return v2->m_pData->m_u.pHash->isEmpty() ? CMP_THISGREATER : CMP_EQUAL;
@@ -891,7 +891,7 @@ public:
return v2->m_pData->m_u.pHash->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
}
- static inline int compare_boolean_array(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_boolean_array(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.bBoolean)
return v2->m_pData->m_u.pArray->isEmpty() ? CMP_THISGREATER : CMP_EQUAL;
@@ -899,7 +899,7 @@ public:
return v2->m_pData->m_u.pArray->isEmpty() ? CMP_EQUAL : CMP_OTHERGREATER;
}
- static inline int compare_boolean_hobject(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_boolean_hobject(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.bBoolean)
return v2->m_pData->m_u.hObject == ((kvs_hobject_t)0) ? CMP_THISGREATER : CMP_EQUAL;
@@ -907,21 +907,21 @@ public:
return v2->m_pData->m_u.hObject == ((kvs_hobject_t)0) ? CMP_EQUAL : CMP_OTHERGREATER;
}
- static inline int compare_array_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_array_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v1->m_pData->m_u.pArray->size() > v2->m_pData->m_u.pHash->size())return CMP_THISGREATER;
if(v1->m_pData->m_u.pArray->size() == v2->m_pData->m_u.pHash->size())return CMP_EQUAL;
return CMP_OTHERGREATER;
}
- static inline int compare_hobject_hash(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_hobject_hash(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v2->m_pData->m_u.pHash->isEmpty())
return v1->m_pData->m_u.hObject == ((kvs_hobject_t)0) ? CMP_EQUAL : CMP_OTHERGREATER;
return v1->m_pData->m_u.hObject == ((kvs_hobject_t)0) ? CMP_THISGREATER : CMP_EQUAL;
}
- static inline int compare_hobject_array(KviKvsVariant * v1,KviKvsVariant * v2)
+ static inline int compare_hobject_array(const KviKvsVariant * v1,const KviKvsVariant * v2)
{
if(v2->m_pData->m_u.pArray->isEmpty())
return v1->m_pData->m_u.hObject == ((kvs_hobject_t)0) ? CMP_EQUAL : CMP_OTHERGREATER;
@@ -1383,7 +1383,7 @@ KviKvsVariant* KviKvsVariant::unserialize(const QString& data)
return pResult;
}
-int KviKvsVariant::compare(KviKvsVariant * pOther,bool bPreferNumeric)
+int KviKvsVariant::compare(const KviKvsVariant * pOther,bool bPreferNumeric) const
{
// returns -1 if this variant is greater than pOther
// 0 if they are considered to be equal
diff --git a/src/kvirc/kvs/kvi_kvs_variant.h b/src/kvirc/kvs/kvi_kvs_variant.h
index 9070e2c25..186114329 100644
--- a/src/kvirc/kvs/kvi_kvs_variant.h
+++ b/src/kvirc/kvs/kvi_kvs_variant.h
@@ -179,7 +179,7 @@ public:
// returns -1 if this variant is greater than the other, 0 if are equal, 1 if the other is greater
// if bPreferNumeric is true then when comparing strings a conversion to a numeric format
// is first attempted.
- int compare(KviKvsVariant * pOther,bool bPreferNumeric = false);
+ int compare(const KviKvsVariant * pOther,bool bPreferNumeric = false) const;
void operator = (const KviKvsVariant &v){ copyFrom(v); };
diff --git a/src/kvirc/ui/kvi_console.cpp b/src/kvirc/ui/kvi_console.cpp
index dadb83a1a..1d80df5a4 100644
--- a/src/kvirc/ui/kvi_console.cpp
+++ b/src/kvirc/ui/kvi_console.cpp
@@ -504,7 +504,7 @@ void KviConsole::updateUri()
if(server)
{
KviIrcUrl::join(uri,server);
- KviChannel * last =connection()->channelList()->getLast();
+ KviChannel * last =connection()->channelList()->last();
for(KviChannel * c = connection()->channelList()->first();c;c = connection()->channelList()->next())
{
uri.append(c->name());
diff --git a/src/modules/context/libkvicontext.cpp b/src/modules/context/libkvicontext.cpp
index 28f3fb1bf..f205b5930 100644
--- a/src/modules/context/libkvicontext.cpp
+++ b/src/modules/context/libkvicontext.cpp
@@ -1,6 +1,6 @@
//=============================================================================
//
-// File : libkvistr.cpp
+// File : libkvicontext.cpp
// Creation date : Wed Jan 02 2007 03:04:12 GMT by Szymon Stefanek
//
// This file is part of the KVirc irc client distribution
@@ -72,31 +72,61 @@
return true; \
}
+/*
+ @doc: context.networkName
+ @type:
+ function
+ @title:
+ $context.networkName
+ @short:
+ Returns the IRC network name of an IRC context
+ @syntax:
+ <string> $contex.networkName
+ <string> $contex.networkName(<irc_context_id:uint>)
+ @description:
+ Returns the name of the network for the specified IRC context.
+ If no irc_context_id is specified then the current irc_context is used.
+ If the irc_context_id specification is not valid then this function
+ returns nothing. If the specified IRC context is not currently connected
+ then this function returns nothing.
+ @seealso:
+ $context.serverHostName
+*/
+
+STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
+ context_kvs_fnc_networkName,
+ c->returnValue()->setString(pConnection->target()->network()->name())
+ )
/*
- @doc: context.serverName
+ @doc: context.serverHostName
@type:
function
@title:
- $context.serverName
+ $context.serverHostName
@short:
Returns the IRC server name of an IRC context
@syntax:
- <string> $contex.serverName
- <string> $contex.serverName(<irc_context_id:uint>)
+ <string> $contex.serverHostName
+ <string> $contex.serverHostName(<irc_context_id:uint>)
@description:
- Returns the name of the IRC server for the specified irc context.
+ Returns the host name of the IRC server that was used to perform
+ the connection in the specified irc context.
If no irc_context_id is specified then the current irc_context is used.
If the irc_context_id specification is not valid then this function
returns nothing. If the specified IRC context is not currently connected
then this function returns nothing.
+ If the returned value is non empty then it will always be a valid
+ DNS hostname that can be used to perform a real connection.
+ Please note that this is different from $my.server() which might
+ return an invalid DNS entry.
@seealso:
$context.serverPort, $context.serverIpAddress, $context.serverPassword
*/
STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
- context_kvs_fnc_serverName,
+ context_kvs_fnc_serverHostName,
c->returnValue()->setString(pConnection->target()->server()->hostName())
)
@@ -118,7 +148,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
returns nothing. If the specified IRC context is not currently connected
then this function returns nothing.
@seealso:
- $context.serverPort, $context.serverName, $context.serverPassword
+ $context.serverPort, $context.serverHostName, $context.serverPassword
*/
STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
@@ -127,6 +157,60 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
)
/*
+ @doc: context.serverIsIPV6
+ @type:
+ function
+ @title:
+ $context.serverIsIPV6
+ @short:
+ Returns the IPV6 state of an IRC context
+ @syntax:
+ <string> $contex.serverIsIPV6
+ <string> $contex.serverIsIPV6(<irc_context_id:uint>)
+ @description:
+ Returns true if the current irc context connection runs over IPV6.
+ If no irc_context_id is specified then the current irc_context is used.
+ If the irc_context_id specification is not valid then this function
+ returns nothing (that evaluates to false). If the specified IRC context
+ is not currently connected then this function returns nothing (that
+ evaluates to false).
+ @seealso:
+ $context.serverPort, $context.serverHostName, $context.serverPassword
+*/
+
+STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
+ context_kvs_fnc_serverIsIPV6,
+ c->returnValue()->setBoolean(pConnection->target()->server()->isIpV6())
+ )
+
+/*
+ @doc: context.serverIsSSL
+ @type:
+ function
+ @title:
+ $context.serverIsSSL
+ @short:
+ Returns the SSL state of an IRC context
+ @syntax:
+ <string> $contex.serverIsSSL
+ <string> $contex.serverIsSSL(<irc_context_id:uint>)
+ @description:
+ Returns true if the current irc context connection runs over SSL.
+ If no irc_context_id is specified then the current irc_context is used.
+ If the irc_context_id specification is not valid then this function
+ returns nothing (that evaluates to false). If the specified IRC context
+ is not currently connected then this function returns nothing (that
+ evaluates to false).
+ @seealso:
+ $context.serverPort, $context.serverHostName, $context.serverPassword
+*/
+
+STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
+ context_kvs_fnc_serverIsSSL,
+ c->returnValue()->setBoolean(pConnection->target()->server()->useSSL())
+ )
+
+/*
@doc: context.serverPassword
@type:
function
@@ -144,7 +228,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
returns nothing. If the specified IRC context is not currently connected
then this function returns nothing.
@seealso:
- $context.serverName, $context.serverIpAddress, $context.serverPort
+ $context.serverHostName, $context.serverIpAddress, $context.serverPort
*/
STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
@@ -171,7 +255,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
returns nothing. If the specified IRC context is not currently connected
then this function returns nothing.
@seealso:
- $context.serverName, $context.serverIpAddress
+ $context.serverHostName, $context.serverIpAddress
*/
STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
@@ -198,7 +282,7 @@ STANDARD_IRC_CONNECTION_TARGET_PARAMETER(
If the irc_context_id specification is not valid then this function
returns nothing.
@seealso:
- $context.serverName, $context.serverIpAddress
+ $context.serverHostName, $context.serverIpAddress
*/
static bool context_kvs_fnc_state(KviKvsModuleFunctionCall * c)
@@ -250,7 +334,7 @@ static bool context_kvs_fnc_state(KviKvsModuleFunctionCall * c)
Print the names of the currently connected servers
[example]
foreach(%ic,$context.list)
- echo "IRC Context" %ic ": " $context.serverName
+ echo "IRC Context" %ic ": " $context.serverHostName
[/example]
*/
@@ -275,10 +359,13 @@ static bool context_kvs_fnc_list(KviKvsModuleFunctionCall * c)
static bool context_module_init(KviModule * m)
{
- KVSM_REGISTER_FUNCTION(m,"serverName",context_kvs_fnc_serverName);
+ KVSM_REGISTER_FUNCTION(m,"serverHostName",context_kvs_fnc_serverHostName);
KVSM_REGISTER_FUNCTION(m,"serverIpAddress",context_kvs_fnc_serverIpAddress);
KVSM_REGISTER_FUNCTION(m,"serverPort",context_kvs_fnc_serverPort);
+ KVSM_REGISTER_FUNCTION(m,"serverIsIPV6",context_kvs_fnc_serverIsIPV6);
+ KVSM_REGISTER_FUNCTION(m,"serverIsSSL",context_kvs_fnc_serverIsSSL);
KVSM_REGISTER_FUNCTION(m,"serverPassword",context_kvs_fnc_serverPassword);
+ KVSM_REGISTER_FUNCTION(m,"networkName",context_kvs_fnc_networkName);
KVSM_REGISTER_FUNCTION(m,"state",context_kvs_fnc_state);
KVSM_REGISTER_FUNCTION(m,"list",context_kvs_fnc_list);
diff --git a/src/modules/help/index.cpp b/src/modules/help/index.cpp
index 540273d0e..d1c629793 100755
--- a/src/modules/help/index.cpp
+++ b/src/modules/help/index.cpp
@@ -69,23 +69,15 @@
#include <ctype.h>
-#ifndef COMPILE_USE_QT4
-int TermList::compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 )
+int kvi_compare(const Term * p1,const Term * p2)
{
-
- if( ( (Term*)i1 )->frequency == ( (Term*)i2 )->frequency )
-
- return 0;
-
- if( ( (Term*)i1 )->frequency < ( (Term*)i2 )->frequency )
-
- return -1;
-
- return 1;
-
+ if(p1->frequency == p2->frequency)
+ return 0;
+ if(p1->frequency < p2->frequency)
+ return -1;
+ return 1;
}
-#endif
QDataStream &operator>>( QDataStream &s, Document &l )
diff --git a/src/modules/help/index.h b/src/modules/help/index.h
index fc8ab72a9..3d2abd996 100755
--- a/src/modules/help/index.h
+++ b/src/modules/help/index.h
@@ -116,14 +116,9 @@ struct Term {
KviValueList<Document>documents;
};
-class TermList : public KviPtrList<Term>
-{
-public:
- TermList() : KviPtrList<Term>() {}
-#ifndef COMPILE_USE_QT4
- int compareItems( QPtrCollection::Item i1, QPtrCollection::Item i2 );
-#endif
-};
+
+
+#define TermList KviPtrList<Term>
#endif
diff --git a/src/modules/list/listwindow.cpp b/src/modules/list/listwindow.cpp
index a4b23510c..6594d878f 100644
--- a/src/modules/list/listwindow.cpp
+++ b/src/modules/list/listwindow.cpp
@@ -346,8 +346,9 @@ void KviListWindow::exportList()
QString szFile;
if(connection())
{
+ QString szDate = QDateTime::currentDateTime().toString("d MMM yyyy hh-mm");
KviQString::sprintf(szFile,__tr2qs("Channel list for %Q - %Q"),
- &(connection()->networkName()),&(QDateTime::currentDateTime().toString("d MMM yyyy hh-mm")));
+ &(connection()->networkName()),&(szDate));
} else {
szFile = __tr2qs("Channel list");
}
diff --git a/src/modules/logview/logviewmdiwindow.cpp b/src/modules/logview/logviewmdiwindow.cpp
index c282c4c49..8571761cb 100644
--- a/src/modules/logview/logviewmdiwindow.cpp
+++ b/src/modules/logview/logviewmdiwindow.cpp
@@ -226,7 +226,7 @@ void KviLogViewMDIWindow::setupItemList()
{
m_pListView->clear();
KviLogFile *pFile;
- m_logList.begin();
+ //m_logList.begin();
KviLogListViewItem *pLastCategory=0;
KviLogListViewItemFolder *pLastGroupItem;
QString szLastGroup;
diff --git a/src/modules/my/libkvimy.cpp b/src/modules/my/libkvimy.cpp
index e76ebf0f6..b1c5dcafc 100644
--- a/src/modules/my/libkvimy.cpp
+++ b/src/modules/my/libkvimy.cpp
@@ -340,6 +340,10 @@ static bool my_kvs_fnc_serverIsSSL(KviKvsModuleFunctionCall * c)
If the irc context is not connected then an empty string is returned.[br]
If <irc_context_id> is specified this function returns acts as it was called
in that irc_context.[br]
+ Please note that this function returns the name of the server as reported
+ by the server itself. Some servers report a bogus value for this field.
+ You should take a look at $context.serverIpAddress or $context.serverHostName
+ if you want a value that can be used to really reconnect to this server.
*/
static bool my_kvs_fnc_server(KviKvsModuleFunctionCall * c)
diff --git a/src/modules/notifier/notifierwindowtabs.cpp b/src/modules/notifier/notifierwindowtabs.cpp
index 3b778ecc1..cca66d387 100644
--- a/src/modules/notifier/notifierwindowtabs.cpp
+++ b/src/modules/notifier/notifierwindowtabs.cpp
@@ -371,17 +371,17 @@ void KviNotifierWindowTabs::prev()
if(!m_pTabFocused)return;
KviNotifierWindowTab * tab;
- QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+ KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
tab = m_tabMap[m_pTabFocused->wnd()];
- tabIterator.atFirst();
+ tabIterator.moveFirst();
while ((tabIterator.current()) != tab) {
++tabIterator;
}
- if (!tabIterator.atFirst()) {
+ if (!tabIterator.moveFirst()) {
--tabIterator;
tab = tabIterator.current();
setFocusOn(tab);
@@ -394,15 +394,15 @@ void KviNotifierWindowTabs::next()
if(!m_pTabFocused)return;
KviNotifierWindowTab * tab;
- QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+ KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
tab = m_tabMap[m_pTabFocused->wnd()];
- tabIterator.atFirst();
+ tabIterator.moveFirst();
while ((tabIterator.current()) != tab) {
++tabIterator;
}
- if (!tabIterator.atLast()) {
+ if (!tabIterator.moveLast()) {
++tabIterator;
tab = tabIterator.current();
setFocusOn(tab);
@@ -514,9 +514,7 @@ void KviNotifierWindowTabs::setFocusOn(KviNotifierWindowTab * tab)
m_pTabFocused = tab;
if(m_pTabFocused)m_pTabFocused->setFocused();
- if (m_lastVisitedTabPtrList.containsRef(tab)) {
- m_lastVisitedTabPtrList.removeRef(tab);
- }
+ m_lastVisitedTabPtrList.removeRef(tab);
m_lastVisitedTabPtrList.insert(0, tab);
@@ -554,14 +552,14 @@ void KviNotifierWindowTabs::draw(QPainter * p)
m_pPainter->drawPixmap(m_rct.width()-m_pixDX.width(),0,m_pixDX);
m_pPainter->drawTiledPixmap(m_pixSX.width(),0,m_rct.width()-m_pixSX.width()-m_pixDX.width(),m_rct.height(),m_pixBKG);
- QPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
+ KviPtrListIterator<KviNotifierWindowTab> tabIterator (m_tabPtrList);
//m_tabPtrList.findRef(m_tabMap[m_pTabFocused->wnd()]);
// QMap<KviWindow *, KviNotifierWindowTab *>::Iterator tab;
KviNotifierWindowTab * tab;
//for (tab = m_tabMap.begin(); tab != m_tabMap.end() && !isBigger; tab++ )
- tabIterator.toFirst();
+ tabIterator.moveFirst();
int i = 0;
while(m_iTabToStartFrom!=i) {
@@ -694,9 +692,9 @@ void KviNotifierWindowTabs::closeTab(KviWindow * pWnd, KviNotifierWindowTab * pT
} else {
if (m_lastVisitedTabPtrList.count()) {
- m_pTabFocused = m_lastVisitedTabPtrList.getFirst();
+ m_pTabFocused = m_lastVisitedTabPtrList.first();
} else {
- m_pTabFocused = m_tabPtrList.getLast();
+ m_pTabFocused = m_tabPtrList.last();
}
m_pTabFocused->setFocused(true);
diff --git a/src/modules/notifier/notifierwindowtabs.h b/src/modules/notifier/notifierwindowtabs.h
index 221a834ed..8b92eb091 100644
--- a/src/modules/notifier/notifierwindowtabs.h
+++ b/src/modules/notifier/notifierwindowtabs.h
@@ -37,14 +37,6 @@
#include "notifiermessage.h"
-#ifdef COMPILE_USE_QT4
- #define QPtrList Q3PtrList
- #define QPtrListIterator Q3PtrListIterator
- #include <q3ptrlist.h>
-#else
- #include <qptrlist.h>
- //#include <qptrlistiterator.h>
-#endif
class QPainter;
class KviWindow;
@@ -149,8 +141,8 @@ private:
QPoint m_pnt;
QMap<KviWindow *, KviNotifierWindowTab *> m_tabMap;
- QPtrList<KviNotifierWindowTab> m_tabPtrList;
- QPtrList<KviNotifierWindowTab> m_lastVisitedTabPtrList;
+ KviPtrList<KviNotifierWindowTab> m_tabPtrList;
+ KviPtrList<KviNotifierWindowTab> m_lastVisitedTabPtrList;
QFont * m_pFocusedFont;
QFont * m_pUnfocusedFont;
diff --git a/src/modules/objects/class_list.cpp b/src/modules/objects/class_list.cpp
index d51daf33e..d798cad2f 100644
--- a/src/modules/objects/class_list.cpp
+++ b/src/modules/objects/class_list.cpp
@@ -261,9 +261,9 @@ bool KviKvsObject_list::function_removeCurrent(KviKvsObjectFunctionCall *c)
c->returnValue()->setBoolean(false);
return true;
}
- if(m_pDataList->currentNode())
+ if(m_pDataList->current())
{
- m_pDataList->removeNode(m_pDataList->currentNode());
+ m_pDataList->removeCurrent();
c->returnValue()->setBoolean(true);
} else {
c->returnValue()->setBoolean(false);
@@ -355,6 +355,12 @@ bool KviKvsObject_list::function_clear(KviKvsObjectFunctionCall *c)
m_pDataList->clear();
return true;
}
+
+inline int kvi_compare(const KviKvsVariant * p1,const KviKvsVariant * p2)
+{
+ return p1->compare(p2);
+}
+
bool KviKvsObject_list::function_sort(KviKvsObjectFunctionCall *c)
{
if(!m_pDataList)return true;
diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp
index f979da4fb..a7c1d874e 100644
--- a/src/modules/url/libkviurl.cpp
+++ b/src/modules/url/libkviurl.cpp
@@ -17,7 +17,6 @@
// Inc. ,59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
//
-
#include "kvi_styled_controls.h"
#include "kvi_module.h"
#include "libkviurl.h"
@@ -213,11 +212,11 @@ void UrlDialog::remove()
QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Select an URL."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
return;
}
+
for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next())
{
if (tmp->url == m_pUrlList->currentItem()->text(0)) {
- g_pList->find(tmp);
- g_pList->remove();
+ g_pList->removeRef(tmp);
m_pUrlList->takeItem(m_pUrlList->currentItem());
return;
}
@@ -468,7 +467,11 @@ void BanFrame::removeBan()
KviStr item(m_pBanList->text(i).utf8().data());
for(KviStr *tmp=g_pBanList->first();tmp;tmp=g_pBanList->next())
{
- if (*tmp == item) g_pBanList->remove();
+ if (*tmp == item)
+ {
+ g_pBanList->removeCurrent();
+ return;
+ }
}
m_pBanList->removeItem(i);