~ubuntu-branches/ubuntu/oneiric/kdepim/oneiric-updates

« back to all changes in this revision

Viewing changes to korganizer/urihandler.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2011-06-28 19:33:24 UTC
  • mfrom: (0.2.13) (0.1.13 sid)
  • Revision ID: package-import@ubuntu.com-20110628193324-8yvjs8sdv9rdoo6c
Tags: 4:4.7.0-0ubuntu1
* New upstream release
  - update install files
  - add missing kdepim-doc package to control file
  - Fix Vcs lines
  - kontact breaks/replaces korganizer << 4:4.6.80
  - tighten the dependency of kdepim-dev on libkdepim4 to fix lintian error

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*
2
 
  This file is part of KOrganizer.
3
 
 
4
 
  Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org>
5
 
  Copyright (c) 2005 Rafal Rzepecki <divide@users.sourceforge.net>
6
 
 
7
 
  This program is free software; you can redistribute it and/or modify
8
 
  it under the terms of the GNU General Public License as published by
9
 
  the Free Software Foundation; either version 2 of the License, or
10
 
  (at your option) any later version.
11
 
 
12
 
  This program is distributed in the hope that it will be useful,
13
 
  but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 
  GNU General Public License for more details.
16
 
 
17
 
  You should have received a copy of the GNU General Public License along
18
 
  with this program; if not, write to the Free Software Foundation, Inc.,
19
 
  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20
 
 
21
 
  As a special exception, permission is given to link this program
22
 
  with any edition of Qt, and distribute the resulting executable,
23
 
  without including the source code for Qt in the source distribution.
24
 
*/
25
 
 
26
 
#include "urihandler.h"
27
 
#include <knodeinterface.h>
28
 
#include <kmailinterface.h>
29
 
#include <korganizerinterface.h>
30
 
 
31
 
#include <libkdepim/kdepimprotocols.h>
32
 
 
33
 
#include <kiconloader.h>
34
 
#include <krun.h>
35
 
#include <kapplication.h>
36
 
#include <kshell.h>
37
 
#include <kdebug.h>
38
 
#include <ktoolinvocation.h>
39
 
 
40
 
#include <QObject>
41
 
 
42
 
bool UriHandler::process( const QString &uri )
43
 
{
44
 
  kDebug() << uri;
45
 
 
46
 
  if ( uri.startsWith( KDEPIMPROTOCOL_EMAIL ) ) {
47
 
    // make sure kmail is running or the part is shown
48
 
    KToolInvocation::startServiceByDesktopPath( "kmail" );
49
 
 
50
 
    // parse string, show
51
 
    int colon = uri.indexOf( ':' );
52
 
    // extract 'number' from 'kmail:<number>/<id>'
53
 
    QString serialNumberStr = uri.mid( colon + 1 );
54
 
    serialNumberStr = serialNumberStr.left( serialNumberStr.indexOf( '/' ) );
55
 
 
56
 
    org::kde::kmail::kmail kmail(
57
 
      "org.kde.kmail", "/KMail", QDBusConnection::sessionBus() );
58
 
    kmail.showMail( serialNumberStr.toUInt(), QString() );
59
 
    return true;
60
 
  } else if ( uri.startsWith( QLatin1String( "mailto:" ) ) ) {
61
 
    KToolInvocation::invokeMailer( uri.mid(7), QString() );
62
 
    return true;
63
 
  } else if ( uri.startsWith( KDEPIMPROTOCOL_CONTACT ) ) {
64
 
    if ( QDBusConnection::sessionBus().interface()->isServiceRegistered(
65
 
           "org.kde.kaddressbook" ) ) {
66
 
/*FIXME: use external contact viewer
67
 
      kapp->updateRemoteUserTimestamp( "org.kde.kaddressbook" );
68
 
      org::kde::KAddressbook::Core kaddressbook(
69
 
        "org.kde.kaddressbook", "/KAddressBook", QDBusConnection::sessionBus() );
70
 
      kaddressbook.showContactEditor( uri.mid( ::qstrlen( KDEPIMPROTOCOL_CONTACT ) ) );
71
 
*/
72
 
      return true;
73
 
    } else {
74
 
      /*
75
 
        KaddressBook is not already running.  Pass it the UID of the contact via
76
 
        the command line while starting it - it is neater.
77
 
        We start it without its main interface
78
 
      */
79
 
      QString iconPath =
80
 
        KIconLoader::global()->iconPath( "view-pim-contacts", KIconLoader::SizeSmall );
81
 
#if 0
82
 
      QString tmpStr = "kaddressbook --editor-only --uid ";
83
 
      tmpStr += KShell::quoteArg( uri.mid( ::qstrlen( KDEPIMPROTOCOL_CONTACT ) ) );
84
 
#endif
85
 
      QString tmpStr = "kaddressbook";
86
 
      KRun::runCommand( tmpStr, "KAddressBook", iconPath, 0 );
87
 
      return true;
88
 
    }
89
 
  } else if ( uri.startsWith( KDEPIMPROTOCOL_INCIDENCE ) ) {
90
 
    // make sure korganizer is running or the part is shown
91
 
    KToolInvocation::startServiceByDesktopPath( "korganizer" );
92
 
 
93
 
    // we must work around KUrl breakage (it doesn't know about URNs)
94
 
    QString uid = KUrl::fromPercentEncoding( uri.toLatin1() ).mid( 11 );
95
 
    OrgKdeKorganizerKorganizerInterface korganizerIface(
96
 
      "org.kde.korganizer", "/Korganizer", QDBusConnection::sessionBus() );
97
 
 
98
 
    return korganizerIface.showIncidence( uid );
99
 
  } else if ( uri.startsWith( KDEPIMPROTOCOL_NEWSARTICLE ) ) {
100
 
    KToolInvocation::startServiceByDesktopPath( "knode" );
101
 
    org::kde::knode knode(
102
 
      "org.kde.knode", "/KNode", QDBusConnection::sessionBus() );
103
 
    knode.openURL( uri );
104
 
  } else {  // no special URI, let KDE handle it
105
 
    new KRun( KUrl( uri ), 0 );
106
 
  }
107
 
 
108
 
  return false;
109
 
}