summaryrefslogtreecommitdiffstats
path: root/kalarm/kalarmd/clientinfo.cpp
diff options
context:
space:
mode:
authortoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
committertoma <toma@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2009-11-25 17:56:58 +0000
commit460c52653ab0dcca6f19a4f492ed2c5e4e963ab0 (patch)
tree67208f7c145782a7e90b123b982ca78d88cc2c87 /kalarm/kalarmd/clientinfo.cpp
downloadtdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.tar.gz
tdepim-460c52653ab0dcca6f19a4f492ed2c5e4e963ab0.zip
Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features.
BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdepim@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kalarm/kalarmd/clientinfo.cpp')
-rw-r--r--kalarm/kalarmd/clientinfo.cpp110
1 files changed, 110 insertions, 0 deletions
diff --git a/kalarm/kalarmd/clientinfo.cpp b/kalarm/kalarmd/clientinfo.cpp
new file mode 100644
index 000000000..21889082e
--- /dev/null
+++ b/kalarm/kalarmd/clientinfo.cpp
@@ -0,0 +1,110 @@
+/*
+ * clientinfo.cpp - client application information
+ * Program: KAlarm's alarm daemon (kalarmd)
+ * Copyright (C) 2001, 2004 by David Jarvie <software@astrojar.org.uk>
+ *
+ * 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.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#include "adcalendar.h"
+#include "clientinfo.h"
+
+QMap<QCString, ClientInfo*> ClientInfo::mClients;
+
+
+ClientInfo::ClientInfo(const QCString& appName, const QString& title,
+ const QCString& dcopObj, const QString& calendar, bool startClient)
+ : mAppName(appName),
+ mTitle(title),
+ mDcopObject(dcopObj),
+ mCalendar(new ADCalendar(calendar, appName)),
+ mStartClient(startClient)
+{
+ mClients[mAppName] = this;
+}
+
+ClientInfo::ClientInfo(const QCString& appName, const QString& title,
+ const QCString& dcopObj, ADCalendar* calendar, bool startClient)
+ : mAppName(appName),
+ mTitle(title),
+ mDcopObject(dcopObj),
+ mCalendar(calendar),
+ mStartClient(startClient)
+{
+ mClients[mAppName] = this;
+}
+
+ClientInfo::~ClientInfo()
+{
+ delete mCalendar;
+ mClients.remove(mAppName);
+}
+
+/******************************************************************************
+* Set a new calendar for the specified client application.
+*/
+ADCalendar* ClientInfo::setCalendar(const QString& url)
+{
+ if (url != mCalendar->urlString())
+ {
+ delete mCalendar;
+ mCalendar = new ADCalendar(url, mAppName);
+ }
+ return mCalendar;
+}
+
+/******************************************************************************
+* Return the ClientInfo object for the specified client application.
+*/
+ClientInfo* ClientInfo::get(const QCString& appName)
+{
+ if (appName.isEmpty())
+ return 0;
+ QMap<QCString, ClientInfo*>::ConstIterator it = mClients.find(appName);
+ if (it == mClients.end())
+ return 0;
+ return it.data();
+}
+
+/******************************************************************************
+* Return the ClientInfo object for client which owns the specified calendar.
+*/
+ClientInfo* ClientInfo::get(const ADCalendar* cal)
+{
+ for (ClientInfo::ConstIterator it = ClientInfo::begin(); it != ClientInfo::end(); ++it)
+ if (it.data()->calendar() == cal)
+ return it.data();
+ return 0;
+}
+
+/******************************************************************************
+* Delete all clients.
+*/
+void ClientInfo::clear()
+{
+ QMap<QCString, ClientInfo*>::Iterator it;
+ while ((it = mClients.begin()) != mClients.end())
+ delete it.data();
+}
+
+/******************************************************************************
+* Delete the client with the specified name.
+*/
+void ClientInfo::remove(const QCString& appName)
+{
+ QMap<QCString, ClientInfo*>::Iterator it = mClients.find(appName);
+ if (it != mClients.end())
+ delete it.data();
+}