[prev in list] [next in list] [prev in thread] [next in thread]
List: kde-commits
Subject: [Konversation] 6e06f52: Enhancing server to keep track of nick
From: Gary Cramblitt <garycramblitt () comcast ! net>
Date: 2010-07-01 13:27:17
Message-ID: 20100701132717.873F2BB5582 () projects ! kde ! org
[Download RAW message or body]
A konversation/nickinfo.h [License: UNKNOWN]
A konversation/nickinfo.cpp [License: Trivialfile.]
commit 6e06f52f0a000b055c09fbc98e5f56c44a604396
Author: Gary Cramblitt <garycramblitt@comcast.net>
Date: Sun Jan 18 03:07:55 2004 +0000
Enhancing server to keep track of nick information. Here are some \
basic data structures and methods that will be needed.
svn path=/trunk/kdeextragear-2/konversation/; revision=280647
diff --git a/konversation/Makefile.am b/konversation/Makefile.am
index 3a778db..cbb4410 100644
--- a/konversation/Makefile.am
+++ b/konversation/Makefile.am
@@ -3,7 +3,7 @@ bin_PROGRAMS = konversation
## INCLUDES were found outside kdevelop specific part
-konversation_SOURCES = konviface.skel konversationmainwindow.cpp \
valuelistviewitem.cpp urlcatcher.cpp searchdialog.cpp \
prefspagehighlight.cpp scriptlauncher.cpp rawlog.cpp prefspagenotify.cpp \
prefspagedialogs.cpp prefspagecolorsimages.cpp prefspagebuttons.cpp \
konvdcop.cpp channellistpanel.cpp konsolepanel.cpp dcctransferhandler.cpp \
prefspageignore.cpp ircresolver.cpp identity.cpp statuspanel.cpp \
prefspageappearance.cpp dccrecipientdialog.cpp topiccombobox.cpp \
prefspagegeneralsettings.cpp prefspagelog.cpp prefspagedccsettings.cpp \
prefspagescripts.cpp nicksonline.cpp prefspageidentity.cpp prefspage.cpp \
prefspageserverlist.cpp dccpanel.cpp dcctransfer.cpp ledlistviewitem.cpp \
highlight.cpp highlightviewitem.cpp nickchangedialog.cpp modebutton.cpp \
ignorelistviewitem.cpp ignorecheckbox.cpp ignore.cpp nicklistview.cpp \
ircinput.cpp ledtabbar.cpp ledtab.cpp ledtabwidget.cpp images.cpp \
editserverdialog.cpp serverlistitem.cpp serverentry.cpp prefsdialog.cpp \
quickbutton.cpp preferences. cpp chatwindow.cpp outputfilter.cpp query.cpp \
konversationapplication.cpp nick.cpp inputfilter.cpp channel.cpp \
ircview.cpp server.cpp ircserversocket.cpp main.cpp prefspageirccolorsui.ui \
prefspageirccolors.cpp irccolorchooserui.ui irccolorchooser.cpp \
prefspagealiases.cpp channellistviewitem.cpp osd.cpp prefspageosd.cpp \
ircevent.cpp trayicon.cpp tabaction.cpp prefspagenickcompletion.cpp \
prefspagetabbehavior.cpp dccchat.cpp logfilereader.cpp \
prefspagewebbrowser.cpp multilineedit.cpp +konversation_SOURCES = \
konviface.skel konversationmainwindow.cpp valuelistviewitem.cpp \
urlcatcher.cpp searchdialog.cpp prefspagehighlight.cpp scriptlauncher.cpp \
rawlog.cpp prefspagenotify.cpp prefspagedialogs.cpp \
prefspagecolorsimages.cpp prefspagebuttons.cpp konvdcop.cpp \
channellistpanel.cpp konsolepanel.cpp dcctransferhandler.cpp \
prefspageignore.cpp ircresolver.cpp identity.cpp statuspanel.cpp \
prefspageappearance.cpp dccrecipientdialog.cpp topiccombobox.cpp \
prefspagegeneralsettings.cpp prefspagelog.cpp prefspagedccsettings.cpp \
prefspagescripts.cpp nicksonline.cpp prefspageidentity.cpp prefspage.cpp \
prefspageserverlist.cpp dccpanel.cpp dcctransfer.cpp ledlistviewitem.cpp \
highlight.cpp highlightviewitem.cpp nickchangedialog.cpp modebutton.cpp \
ignorelistviewitem.cpp ignorecheckbox.cpp ignore.cpp nicklistview.cpp \
ircinput.cpp ledtabbar.cpp ledtab.cpp ledtabwidget.cpp images.cpp \
editserverdialog.cpp serverlistitem.cpp serverentry.cpp prefsdialog.cpp \
quickbutton.cpp preferences. cpp chatwindow.cpp outputfilter.cpp query.cpp \
konversationapplication.cpp nick.cpp inputfilter.cpp channel.cpp \
ircview.cpp server.cpp ircserversocket.cpp main.cpp prefspageirccolorsui.ui \
prefspageirccolors.cpp irccolorchooserui.ui irccolorchooser.cpp \
prefspagealiases.cpp channellistviewitem.cpp osd.cpp prefspageosd.cpp \
ircevent.cpp trayicon.cpp tabaction.cpp prefspagenickcompletion.cpp \
prefspagetabbehavior.cpp dccchat.cpp logfilereader.cpp \
prefspagewebbrowser.cpp multilineedit.cpp nickinfo.cpp konversation_LDADD \
= $(LIB_KIO) -lm
@@ -45,4 +45,4 @@ messages: rc.cpp
if test -n "$$LIST"; then \
$(XGETTEXT) $$LIST -o $(podir)/konversation.pot; \
fi
-noinst_HEADERS = prefspagetabbehavior.h dccchat.h logfilereader.h \
prefspagewebbrowser.h multilineedit.h +noinst_HEADERS = \
prefspagetabbehavior.h dccchat.h logfilereader.h prefspagewebbrowser.h \
multilineedit.h nickinfo.h
diff --git a/konversation/nickinfo.cpp b/konversation/nickinfo.cpp
new file mode 100644
index 0000000..98ec3ee
--- /dev/null
+++ b/konversation/nickinfo.cpp
@@ -0,0 +1,56 @@
+/*
+ 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.
+*/
+
+/*
+ nickinfo.cpp - Nick Information
+ begin: Sat Jan 17 2004
+ copyright: (C) 2004 by Gary Cramblitt
+ email: garycramblitt@comcast.net
+*/
+
+#include "nickinfo.h"
+
+/*
+ @author Gary Cramblitt
+*/
+
+/*
+ The NickInfo object is a data container for information about a single \
nickname. + It is owned by the Server object and should NOT be deleted by \
anything other than Server. + If using code alters the NickInfo object, it \
should call Server::nickInfoUpdated to + let Server know that the object \
has been modified. +*/
+
+NickInfo::NickInfo(Server* server)
+{
+ owningServer = server;
+}
+NickInfo::~NickInfo()
+{
+}
+
+
+// Get properties of NickInfo object.
+QString NickInfo::getHostmask() { return hostmask; }
+bool NickInfo::isAway() { return away; }
+QString NickInfo::getAwayMessage() { return awayMessage; }
+QString NickInfo::getIdentdInfo() { return identdInfo; }
+QString NickInfo::getVersionInfo() { return versionInfo; }
+bool NickInfo::isNotified() { return notified; }
+
+// Return the Server object that owns this NickInfo object.
+Server* NickInfo::getServer() { return owningServer; }
+
+// Set properties of NickInfo object.
+// If any of these are called, call Server::nickInfoUpdated to let Server \
know about the change. +void NickInfo::setHostmask(const QString& newMask) \
{ hostmask = newMask; } +void NickInfo::setAway(bool state) { away = state; \
} +void NickInfo::setAwayMessage(const QString& newMessage) { awayMessage = \
newMessage; } +void NickInfo::setIdentdInfo(const QString& newIdentdInfo) \
{identdInfo = newIdentdInfo; } +void NickInfo::setVersionInfo(const \
QString& newVersionInfo) { versionInfo = newVersionInfo; } +void \
NickInfo::setNotified(bool state) { notified = state; } +
diff --git a/konversation/nickinfo.h b/konversation/nickinfo.h
new file mode 100644
index 0000000..9d971a3
--- /dev/null
+++ b/konversation/nickinfo.h
@@ -0,0 +1,69 @@
+/*
+ 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.
+*/
+
+/*
+ nickinfo.h - Nick Information
+ begin: Sat Jan 17 2004
+ copyright: (C) 2004 by Gary Cramblitt
+ email: garycramblitt@comcast.net
+*/
+
+#ifndef NICKINFO_H
+#define NICKINFO_H
+
+/*
+ @author Gary Cramblitt
+*/
+
+#include <qstringlist.h>
+
+class Server;
+
+/*
+ The NickInfo object is a data container for information about a single \
nickname. + It is owned by the Server object and should NOT be deleted by \
anything other than Server. + If using code alters the NickInfo object, it \
should call Server::nickInfoUpdated to + let Server know that the object \
has been modified. +*/
+
+class NickInfo
+{
+ public:
+ NickInfo(Server* server);
+ ~NickInfo();
+
+ // Get properties of NickInfo object.
+ QString getHostmask();
+ bool isAway();
+ QString getAwayMessage();
+ QString getIdentdInfo();
+ QString getVersionInfo();
+ bool isNotified();
+
+ // Return the Server object that owns this NickInfo object.
+ Server* getServer();
+
+ // Set properties of NickInfo object.
+ // If any of these are called, call Server::nickInfoUpdated to let \
Server know about the change. + void setHostmask(const QString& \
newMask); + void setAway(bool state);
+ void setAwayMessage(const QString& newMessage);
+ void setIdentdInfo(const QString& newIdentdInfo);
+ void setVersionInfo(const QString& newVersionInfo);
+ void setNotified(bool state);
+
+ protected:
+ Server* owningServer;
+ QString hostmask;
+ bool away;
+ QString awayMessage;
+ QString identdInfo;
+ QString versionInfo;
+ bool notified;
+};
+
+#endif
diff --git a/konversation/server.cpp b/konversation/server.cpp
index f184f57..552df67 100644
--- a/konversation/server.cpp
+++ b/konversation/server.cpp
@@ -799,6 +799,81 @@ QString Server::getNumericalIp()
return QString::number(ip.ip4Addr());
}
+// Given a nickname, returns NickInfo object. 0 if not found.
+NickInfo* Server::getNickInfo(const QString& nickName)
+{
+ return allNicks.find(nickName);
+/*
+ NickInfo* nickInfo;
+ NickInfoList* members;
+ // Search joined channels.
+ ChannelMembershipListIterator joinedChannelIterator(joinedChannels);
+ for( ; (members=joinedChannelIterator.current()); \
++joinedChannelIterator ) + {
+ nickInfo = members->find(nickName);
+ if (nickInfo) return nickInfo;
+ }
+ // Search unjoined channels.
+ ChannelMembershipListIterator unjoinedChannelIterator(unjoinedChannels);
+ for( ; (members=unjoinedChannelIterator.current()); \
++unjoinedChannelIterator ) + {
+ nickInfo = members->find(nickName);
+ if (nickInfo) return nickInfo;
+ }
+ // Search Queries.
+ nickInfo = queryNicks.find(nickname);
+ if (nickInfo) return nickInfo;
+ // Search nicks online.
+ nickInfo = nicksOnline.find(nickname);
+ if (nickInfo) return nickInfo;
+ // Search nicks offline.
+ nickInfo = nicksOffline.find(nickname);
+ return nickInfo;
+*/
+}
+
+// Returns the list of members for a channel in the joinedChannels list. \
0 if channel is not in the joinedChannels list. +// Using code must not \
alter the list. +const NickInfoList* Server::getJoinedChannelMembers(const \
QString& channelName) +{
+ return joinedChannels.find(channelName);
+}
+
+// Returns the list of members for a channel in the unjoinedChannels list. \
0 if channel is not in the unjoinedChannels list. +// Using code must not \
alter the list. +const NickInfoList* \
Server::getUnjoinedChannelMembers(const QString& channelName) +{
+ return unjoinedChannels.find(channelName);
+}
+
+// Searches the Joined and Unjoined lists for the given channel and \
returns the member list. 0 if channel is not in either list. +// Using \
code must not alter the list. +const NickInfoList* \
Server::getChannelMembers(const QString& channelName) +{
+ const NickInfoList* members = getJoinedChannelMembers(channelName);
+ if (!members) members = getUnjoinedChannelMembers(channelName);
+ return members;
+}
+
+// Returns a list of all the channels (joined or unjoined) that a nick is \
in. +QStringList Server::getNickChannels(QString& nickName)
+{
+ QStringList channellist;
+ NickInfoList* members;
+ ChannelMembershipListIterator joinedChannelIterator(joinedChannels);
+ for( ; (members=joinedChannelIterator.current()); \
++joinedChannelIterator ) + {
+ if (members->find(nickName)) \
channellist.append(joinedChannelIterator.currentKey()); + }
+ ChannelMembershipListIterator unjoinedChannelIterator(unjoinedChannels);
+ for( ; (members=unjoinedChannelIterator.current()); \
++unjoinedChannelIterator ) + {
+ if (members->find(nickName)) \
channellist.append(unjoinedChannelIterator.currentKey()); + }
+ return channellist;
+}
+
+
QString Server::getIp()
{
// Get our own IP address.
diff --git a/konversation/server.h b/konversation/server.h
index 994551e..05e78b9 100644
--- a/konversation/server.h
+++ b/konversation/server.h
@@ -17,6 +17,7 @@
#include <qtimer.h>
#include <qdatetime.h>
+#include <qdict.h>
#include "inputfilter.h"
#include "outputfilter.h"
@@ -24,6 +25,7 @@
#include "ircresolver.h"
#include "dcctransfer.h"
+#include "nickinfo.h"
/*
@author Dario Abatianni
@@ -37,6 +39,15 @@ class KonversationMainWindow;
class RawLog;
class ChannelListPanel;
+// A NickInfoList is a list of NickInfo objects, indexed by nickname.
+typedef QDict<NickInfo> NickInfoList;
+// A ChannelMembershipList is a list of MemberLists, indexed by channel \
name. +typedef QDict<NickInfoList> ChannelMembershipList;
+// An iterator for a MemberList.
+typedef QDictIterator<NickInfo> NickInfoListIterator;
+// An iterator for a ChannelMembershipList.
+typedef QDictIterator<NickInfoList> ChannelMembershipListIterator;
+
class Server : public QObject
{
Q_OBJECT
@@ -131,6 +142,20 @@ class Server : public QObject
bool connected();
QString getIp();
QString getNumericalIp();
+
+ // Given a nickname, returns NickInfo object. 0 if not found.
+ NickInfo* getNickInfo(const QString& nickName);
+ // Returns the list of members for a channel in the joinedChannels \
list. 0 if channel is not in the joinedChannels list. + // Using code \
must not alter the list. + const NickInfoList* \
getJoinedChannelMembers(const QString& channelName); + // Returns the \
list of members for a channel in the unjoinedChannels list. 0 if channel \
is not in the unjoinedChannels list. + // Using code must not alter the \
list. + const NickInfoList* getUnjoinedChannelMembers(const QString& \
channelName); + // Searches the Joined and Unjoined lists for the given \
channel and returns the member list. 0 if channel is not in either list. + \
// Using code must not alter the list. + const NickInfoList* \
getChannelMembers(const QString& channelName); + // Returns a list of \
all the channels (joined or unjoined) that a nick is in. + QStringList \
getNickChannels(QString& nickName);
signals:
void nicknameChanged(const QString&);
@@ -284,6 +309,21 @@ class Server : public QObject
bool rejoinChannels;
QString nonAwayNick;
+
+ // All nicks known to this server. Note this is NOT a list of nicks \
on the server. + NickInfoList allNicks;
+ // List of membership lists for joined channels. A "joined" channel \
is a channel that user has joined, i.e., + // a tab appears for the \
channel in the main window. + ChannelMembershipList joinedChannels;
+ // List of membership lists for unjoined channels. These come from \
WHOIS responses. Note that this is NOT + // a list of all channels on \
the server, just those we are interested in because of nicks in the Nick \
Watch List. + ChannelMembershipList unjoinedChannels;
+ // List of nicks in the Nick Watch List that are online.
+ NickInfoList nicksOnline;
+ // List of nicks in the Nick Watch List that are not online.
+ NickInfoList nicksOffline;
+ // List of nicks in Queries.
+ NickInfoList queryNicks;
};
#endif
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic