summaryrefslogtreecommitdiffabout
path: root/libkdepim/externalapphandler.h
blob: efcdd899a14403e28e0e94855f52c3710d061dec (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
/*
    This file is part of libkdepim.
    Copyright (c) 2004 Ulf Schenk

    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., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.

    As a special exception, permission is given to link this program
    with any edition of Qt, and distribute the resulting executable,
    without including the source code for Qt in the source distribution.
*/

/*
Enhanced Version of the file for platform independent KDE tools.
Copyright (c) 2004 Ulf Schenk

$Id$
*/

#ifndef EXTERNALAPPHANDLER_H
#define EXTERNALAPPHANDLER_H

#include <qlist.h>

class QCopEnvelope;


class ExternalAppHandler;

class DefaultAppItem
{
  public:
    DefaultAppItem(int type, int id, const QString& label,  const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2)
      : _type(type), _id(id), _label(label), _channel(channel), _message(message), _parameters(parameters), _message2(message2), _parameters2(parameters2)
      {	}

	DefaultAppItem()
	{  }

  public:
    int _type;
    int _id;
    QString _label;
    QString _channel;
    QString _message;
    QString _parameters;	// a list of parameters in stringrepresentation. Delimiter is ;
    QString _message2;
    QString _parameters2;  // a list of parameters in stringrepresentation. Delimiter is ;

};

class ExternalAppHandler
{
  public:
    virtual ~ExternalAppHandler();

    static ExternalAppHandler *instance();

    enum Types {
		EMAIL = 0,
		PHONE = 1,
		SMS   = 2,
		FAX   = 3,
		PAGER = 4
	};

    enum Availability {
		UNDEFINED = -1,
		UNAVAILABLE   = 0,
		AVAILABLE = 1
	};

    //calls the emailapplication with a number of attachments that need to be send
    bool mailAttachments( const QString& urls );

    //calls the emailapplication and creates a mail with parameter emails as recipients
    bool mailToContacts( const QString& emails );

    //calls the phoneapplication with the number
    bool callByPhone( const QString& phonenumber );

    //calls the smsapplication with the number
    bool callBySMS( const QString& phonenumber );

    //calls the pagerapplication with the number
    bool callByPager( const QString& pagernumber );

    //calls the faxapplication with the number
    bool callByFax( const QString& faxnumber );

    bool isEmailAppAvailable();
    bool isSMSAppAvailable();
    bool isPhoneAppAvailable();
    bool isFaxAppAvailable();
    bool isPagerAppAvailable();



    //loadConfig clears the cache and checks again if the applications are available or not
    void loadConfig();

    QList<DefaultAppItem> getAvailableDefaultItems(Types);
    DefaultAppItem* getDefaultItem(Types, int);


  private:
    ExternalAppHandler();
    QList<DefaultAppItem> mDefaultItems;

    Availability mEmailAppAvailable;
    Availability mPhoneAppAvailable;
    Availability mFaxAppAvailable;
    Availability mSMSAppAvailable;
    Availability mPagerAppAvailable;


    void addDefaultAppItem(Types type, int id, const QString& label,  const QString& channel, const QString& message, const QString& parameters, const QString& message2, const QString& parameters2);

    QString& translateMessage(QString& message, const QString& emails) const;
	void passParameter(QCopEnvelope* e, const QString& parameters, const QString& param1) const;


    static ExternalAppHandler *sInstance;


};

#endif