summaryrefslogtreecommitdiff
path: root/libopie2/opiepim/core/opimresolver.h
blob: adc7c16ff4bc0133d7bbf831753f407902b37ba9 (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
/*
                             This file is part of the Opie Project
                             Copyright (C) The Main Author <main-author@whereever.org>
              =.             Copyright (C) The Opie Team <opie-devel@handhelds.org>
            .=l.
           .>+-=
 _;:,     .>    :=|.         This program is free software; you can
.> <`_,   >  .   <=          redistribute it and/or  modify it under
:`=1 )Y*s>-.--   :           the terms of the GNU Library General Public
.="- .-=="i,     .._         License as published by the Free Software
 - .   .-<_>     .<>         Foundation; either version 2 of the License,
     ._= =}       :          or (at your option) any later version.
    .%`+i>       _;_.
    .i_,=:_.      -<s.       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
..}^=.=       =       ;      Library General Public License for more
++=   -.     .`     .:       details.
 :     =  ...= . :.=-
 -.   .:....=;==+<;          You should have received a copy of the GNU
  -_. . .   )=.  =           Library General Public License along with
    --        :-=`           this library; see the file COPYING.LIB.
                             If not, write to the Free Software Foundation,
                             Inc., 59 Temple Place - Suite 330,
                             Boston, MA 02111-1307, USA.
*/
#ifndef OPIE_PIM_RESOLVER
#define OPIE_PIM_RESOLVER

#include <qstring.h>
#include <qvaluelist.h>

#include <opie2/otemplatebase.h>

namespace Opie {
/**
 * OPimResolver is a MetaClass to access
 * available backends read only.
 * It will be used to resolve uids + app names
 * to full informations
 * to traverse through a list of alarms, reminders
 * to get access to built in PIM functionality
 * and to more stuff
 * THE PERFORMANCE will depend on THE BACKEND
 * USING XML is a waste of memory!!!!!
 */
class OPimResolver {
public:
    enum BuiltIn { TodoList = 0,
                   DateBook,
                   AddressBook
    };
    static OPimResolver* self();


    /**
     * return a record for a uid
     * and an service
     * You've THE OWNERSHIP NOW!
     */
    OPimRecord *record( const QString& service, int uid );

    /**
     * return the QCopChannel for service
     * When we will use Qtopia Services it will be used here
     */
    QCString qcopChannel( enum BuiltIn& )const;
    QCString qcopChannel( const QString& service )const;

    /**
     * The Application channel (QPE/Application/name)
     */
    QCString applicationChannel( enum BuiltIn& )const;
    QCString applicationChannel( const QString& service )const;

    /**
     * return a list of available services
     */
    QStringList services()const;
    inline QString serviceName(int rrti )const;
    int serviceId( const QString& Service);
    /**
     * add a record to a service... ;)
     */
    bool add( const QString& service, const OPimRecord& );


    /**
     *  record returns an empty record for a given service.
     *  Be sure to delete it!!!
     *
     */
    OPimRecord* record( const QString& service );
    OPimRecord* record( int rtti );

    /**
     * you can cast to your
     */
    OPimBase* backend( const QString& service );
    OPimBase* backend( int rtti );
private:
    OPimResolver();
    void loadData();
    inline bool isBuiltIn( const QString& )const;
    OPimRecord* recordExtern( const QString&, int );
    OPimRecord* recordExtern( const QString& );

    static OPimResolver* m_self;
    struct Data;
    class Private;

    Data* data;
    Private* d;
    QStringList m_builtIns;
};

}

#endif