~ubuntu-branches/ubuntu/quantal/akonadi/quantal

« back to all changes in this revision

Viewing changes to server/akonadictl/main.cpp

  • Committer: Package Import Robot
  • Author(s): Jonathan Riddell
  • Date: 2012-01-24 23:43:13 UTC
  • mto: (3.1.12 sid)
  • mto: This revision was merged to the branch mainline in revision 69.
  • Revision ID: package-import@ubuntu.com-20120124234313-ooald4uh9w8jilyw
Tags: upstream-1.7.0
ImportĀ upstreamĀ versionĀ 1.7.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
29
29
 
30
30
#include <config-akonadi.h>
31
31
 
32
 
#include "akapplication.h"
 
32
#include <akapplication.h>
 
33
#include <akdbus.h>
33
34
#include "protocol_p.h"
34
35
 
35
36
#include "controlmanagerinterface.h"
46
47
{
47
48
  //Needed for wince build
48
49
  #undef interface
49
 
  if ( QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE) )
50
 
       || QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_SERVER_SERVICE) ) ) {
 
50
  if ( QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Control) )
 
51
       || QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Server) ) ) {
51
52
    qDebug() << "Akonadi is already running.";
52
53
    return false;
53
54
  }
57
58
 
58
59
static bool stopServer()
59
60
{
60
 
  org::freedesktop::Akonadi::ControlManager iface( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE),
 
61
  org::freedesktop::Akonadi::ControlManager iface( AkDBus::serviceName(AkDBus::Control),
61
62
                                                   QLatin1String("/ControlManager"),
62
63
                                                   QDBusConnection::sessionBus(), 0 );
63
64
  if ( !iface.isValid() ) {
72
73
 
73
74
static bool statusServer()
74
75
{
75
 
  bool registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE) );
 
76
  bool registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Control) );
76
77
  qDebug( "Akonadi Control: %s", registered ? "running" : "stopped" );
77
78
 
78
 
  registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_SERVER_SERVICE) );
 
79
  registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Server) );
79
80
  qDebug( "Akonadi Server: %s", registered ? "running" : "stopped" );
80
81
 
81
82
  registered = QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String("org.kde.nepomuk.services.nepomukqueryservice") );
106
107
 
107
108
int main( int argc, char **argv )
108
109
{
109
 
  AkApplication app( argc, argv );
 
110
  AkCoreApplication app( argc, argv );
110
111
  app.setDescription( QLatin1String("Akonadi server manipulation tool\n"
111
112
      "Usage: akonadictl [command]\n\n"
112
113
      "Commands:\n"
113
114
      "  start      : Starts the Akonadi server with all its processes\n"
114
115
      "  stop       : Stops the Akonadi server and all its processes cleanly\n"
115
116
      "  restart    : Restart Akonadi server with all its processes\n"
116
 
      "  status     : Shows a status overview of the Akonadi server"
 
117
      "  status     : Shows a status overview of the Akonadi server\n"
 
118
      "  vacuum     : Vacuum internal storage (WARNING: needs a lot of time and disk space!)\n"
 
119
      "  fsck       : Check (and attempt to fix) consistency of the internal storage (can take some time)"
117
120
  ) );
118
121
 
119
122
  app.parseCommandLine();
120
123
 
121
 
  QString optionsList;
 
124
  QStringList optionsList;
122
125
  optionsList.append( QLatin1String( "start" ) );
123
126
  optionsList.append( QLatin1String( "stop" ) );
124
127
  optionsList.append( QLatin1String( "status" ) );
125
128
  optionsList.append( QLatin1String( "restart" ) );
 
129
  optionsList.append( QLatin1String( "vacuum" ) );
 
130
  optionsList.append( QLatin1String( "fsck" ) );
126
131
 
 
132
  QStringList arguments = QCoreApplication::instance()->arguments();
127
133
#ifndef _WIN32_WCE
128
 
  const QStringList arguments = app.arguments();
 
134
  if ( AkApplication::hasInstanceIdentifier() ) { // HACK: we should port all of this to boost::program_options...
 
135
    arguments.removeFirst();
 
136
    arguments.removeFirst();
 
137
  }
129
138
  if ( arguments.count() != 2 ) {
130
139
    app.printUsage();
131
140
    return 1;
134
143
    return 2;
135
144
  }
136
145
#else
137
 
    QStringList arguments = app.arguments();
138
146
    if (argc > 1) {
139
147
      if (strcmp(argv[1],"start") == 0) {
140
148
        arguments.append(QLatin1String("start"));
177
185
#else
178
186
          Sleep(100000);
179
187
#endif
180
 
        } while( QDBusConnection::sessionBus().interface()->isServiceRegistered( QLatin1String(AKONADI_DBUS_CONTROL_SERVICE) ) );
 
188
        } while( QDBusConnection::sessionBus().interface()->isServiceRegistered( AkDBus::serviceName(AkDBus::Control) ) );
181
189
        if ( !startServer() )
182
190
          return 3;
183
191
      }
 
192
  } else if ( arguments[ 1 ] == QLatin1String( "vacuum" ) ) {
 
193
    QDBusInterface iface( AkDBus::serviceName(AkDBus::StorageJanitor), QLatin1String(AKONADI_DBUS_STORAGEJANITOR_PATH) );
 
194
    iface.call( QDBus::NoBlock, QLatin1String( "vacuum" ) );
 
195
  } else if ( arguments[ 1 ] == QLatin1String( "fsck" ) ) {
 
196
    QDBusInterface iface( AkDBus::serviceName(AkDBus::StorageJanitor), QLatin1String(AKONADI_DBUS_STORAGEJANITOR_PATH) );
 
197
    iface.call( QDBus::NoBlock, QLatin1String( "check" ) );
184
198
  }
185
 
 
186
199
  return 0;
187
200
}