• Skip to content
  • Skip to link menu
KDE 4.2 API Reference
  • KDE API Reference
  • kdepim
  • Sitemap
  • Contact Us
 

kpilot

actionQueue.cc

Go to the documentation of this file.
00001 /* KPilot
00002 **
00003 ** Copyright (C) 1998-2001 by Dan Pilone <dan@kpilot.org>
00004 ** Copyright (C) 2003-2004 Reinhold Kainhofer <reinhold@kainhofer.com>
00005 **
00006 ** This defines the "ActionQueue", which is the pile of actions
00007 ** that will occur during a HotSync.
00008 */
00009 
00010 /*
00011 ** This program is free software; you can redistribute it and/or modify
00012 ** it under the terms of the GNU General Public License as published by
00013 ** the Free Software Foundation; either version 2 of the License, or
00014 ** (at your option) any later version.
00015 **
00016 ** This program is distributed in the hope that it will be useful,
00017 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 ** GNU General Public License for more details.
00020 **
00021 ** You should have received a copy of the GNU General Public License
00022 ** along with this program in a file called COPYING; if not, write to
00023 ** the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
00024 ** MA 02110-1301, USA.
00025 */
00026 
00027 /*
00028 ** Bug reports and questions can be sent to kde-pim@kde.org
00029 */
00030 #include "options.h"
00031 
00032 #include <QtCore/QTimer>
00033 
00034 #include "actions.h"
00035 #include "plugin.h"
00036 
00037 #include "actionQueue.moc"
00038 
00039 ActionQueue::ActionQueue(KPilotLink *d) :
00040     SyncAction(d, "ActionQueue")
00041     // The string lists have default constructors
00042 {
00043     FUNCTIONSETUP;
00044 }
00045 
00046 ActionQueue::~ActionQueue()
00047 {
00048     FUNCTIONSETUP;
00049     clear();
00050 }
00051 
00052 void ActionQueue::clear()
00053 {
00054     SyncAction *del = 0L;
00055     while ( (del = nextAction()) )
00056     {
00057         delete del;
00058     }
00059 
00060     Q_ASSERT(isEmpty());
00061 }
00062 
00063 void ActionQueue::queueInit()
00064 {
00065     FUNCTIONSETUP;
00066 
00067     addAction(new WelcomeAction(fHandle));
00068 }
00069 
00070 void ActionQueue::queueConduits(const QStringList &l,
00071     const SyncAction::SyncMode &m)
00072 {
00073     FUNCTIONSETUP;
00074 
00075     // Add conduits here ...
00076     //
00077     //
00078     for (QStringList::ConstIterator it = l.begin();
00079         it != l.end();
00080         ++it)
00081     {
00082         if ((*it).startsWith(CSL1("internal_")))
00083         {
00084             DEBUGKPILOT << ": Ignoring conduit " << *it;
00085             continue;
00086         }
00087 
00088         DEBUGKPILOT << ": Creating proxy with mode=" << m.name();
00089         ConduitProxy *cp = new ConduitProxy(fHandle,*it,m);
00090         addAction(cp);
00091     }
00092 }
00093 
00094 void ActionQueue::queueCleanup()
00095 {
00096     addAction(new CleanupAction(fHandle));
00097 }
00098 
00099 bool ActionQueue::exec()
00100 {
00101     actionCompleted(0L);
00102     return true;
00103 }
00104 
00105 void ActionQueue::actionCompleted(SyncAction *b)
00106 {
00107     FUNCTIONSETUP;
00108 
00109     if (b)
00110     {
00111         DEBUGKPILOT << ": Completed action " << b->objectName();
00112         b->deleteLater();
00113     }
00114 
00115     if (isEmpty())
00116     {
00117         delayDone();
00118         return;
00119     }
00120     if ( deviceLink() && (!deviceLink()->tickle()) )
00121     {
00122         emit logError(i18n("The connection to the handheld "
00123             "was lost. Synchronization cannot continue."));
00124         clear();
00125         delayDone();
00126         return;
00127     }
00128 
00129     SyncAction *a = nextAction();
00130 
00131     if (!a)
00132     {
00133         WARNINGKPILOT << "NULL action on stack.";
00134         return;
00135     }
00136 
00137     DEBUGKPILOT << ": Will run action " << a->objectName();
00138 
00139     QObject::connect(a, SIGNAL(logMessage(const QString &)),
00140         this, SIGNAL(logMessage(const QString &)));
00141     QObject::connect(a, SIGNAL(logError(const QString &)),
00142         this, SIGNAL(logMessage(const QString &)));
00143     QObject::connect(a, SIGNAL(logProgress(const QString &, int)),
00144         this, SIGNAL(logProgress(const QString &, int)));
00145     QObject::connect(a, SIGNAL(syncDone(SyncAction *)),
00146         this, SLOT(actionCompleted(SyncAction *)));
00147 
00148     // Run the action picked from the queue when we get back
00149     // to the event loop.
00150     QTimer::singleShot(0,a,SLOT(execConduit()));
00151 }
00152 

kpilot

Skip menu "kpilot"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

kdepim

Skip menu "kdepim"
  • akonadi
  •   clients
  •   kabc
  •   kcal
  •   kcm
  • akregator
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt
  • kdgantt1
  • kjots
  • kleopatra
  • kmail
  • kmobiletools
  • knode
  • knotes
  • kontact
  • kontactinterfaces
  • korganizer
  •   korgac
  • kpilot
  • ktimetracker
  •   doc
  • libkdepim
  • libkholidays
  • libkleo
  • libkpgp
  • maildir
Generated for kdepim by doxygen 1.5.4
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal