~ubuntu-branches/ubuntu/utopic/kde-workspace/utopic-proposed

« back to all changes in this revision

Viewing changes to plasma/generic/dataengines/statusnotifieritem/systemtraytypes.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Michał Zając
  • Date: 2011-07-09 08:31:15 UTC
  • Revision ID: james.westby@ubuntu.com-20110709083115-ohyxn6z93mily9fc
Tags: upstream-4.6.90
Import upstream version 4.6.90

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 *                                                                         *
 
3
 *   Copyright (C) 2009 Marco Martin <notmart@gmail.com>                   *
 
4
 *                                                                         *
 
5
 *   This program is free software; you can redistribute it and/or modify  *
 
6
 *   it under the terms of the GNU General Public License as published by  *
 
7
 *   the Free Software Foundation; either version 2 of the License, or     *
 
8
 *   (at your option) any later version.                                   *
 
9
 *                                                                         *
 
10
 *   This program is distributed in the hope that it will be useful,       *
 
11
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
 
12
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
 
13
 *   GNU General Public License for more details.                          *
 
14
 *                                                                         *
 
15
 *   You should have received a copy of the GNU General Public License     *
 
16
 *   along with this program; if not, write to the                         *
 
17
 *   Free Software Foundation, Inc.,                                       *
 
18
 *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA .        *
 
19
 ***************************************************************************/
 
20
 
 
21
#include "systemtraytypes.h"
 
22
 
 
23
 
 
24
// Marshall the ImageStruct data into a D-BUS argument
 
25
const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageStruct &icon)
 
26
{
 
27
    argument.beginStructure();
 
28
    argument << icon.width;
 
29
    argument << icon.height;
 
30
    argument << icon.data;
 
31
    argument.endStructure();
 
32
    return argument;
 
33
}
 
34
#include <KDebug>
 
35
 
 
36
// Retrieve the ImageStruct data from the D-BUS argument
 
37
const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageStruct &icon)
 
38
{
 
39
    qint32 width = 0;
 
40
    qint32 height = 0;
 
41
    QByteArray data;
 
42
 
 
43
    if (argument.currentType() == QDBusArgument::StructureType) {
 
44
        argument.beginStructure();
 
45
        //kDebug() << "begun structure";
 
46
        argument >> width;
 
47
        //kDebug() << width;
 
48
        argument >> height;
 
49
        //kDebug() << height;
 
50
        argument >> data;
 
51
        //kDebug() << data.size();
 
52
        argument.endStructure();
 
53
    }
 
54
 
 
55
    icon.width = width;
 
56
    icon.height = height;
 
57
    icon.data = data;
 
58
 
 
59
    return argument;
 
60
}
 
61
 
 
62
// Marshall the ImageVector data into a D-BUS argument
 
63
const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusImageVector &iconVector)
 
64
{
 
65
    argument.beginArray(qMetaTypeId<KDbusImageStruct>());
 
66
    for (int i=0; i<iconVector.size(); ++i) {
 
67
        argument << iconVector[i]; 
 
68
    }
 
69
    argument.endArray();
 
70
    return argument;
 
71
}
 
72
 
 
73
// Retrieve the ImageVector data from the D-BUS argument
 
74
const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusImageVector &iconVector)
 
75
{
 
76
    iconVector.clear();
 
77
 
 
78
    if (argument.currentType() == QDBusArgument::ArrayType) {
 
79
        argument.beginArray();
 
80
 
 
81
        while (!argument.atEnd()) {
 
82
            KDbusImageStruct element;
 
83
            argument >> element;
 
84
            iconVector.append(element);
 
85
        }
 
86
 
 
87
        argument.endArray();
 
88
    }
 
89
 
 
90
    return argument;
 
91
}
 
92
 
 
93
// Marshall the ToolTipStruct data into a D-BUS argument
 
94
const QDBusArgument &operator<<(QDBusArgument &argument, const KDbusToolTipStruct &toolTip)
 
95
{
 
96
    argument.beginStructure();
 
97
    argument << toolTip.icon;
 
98
    argument << toolTip.image;
 
99
    argument << toolTip.title;
 
100
    argument << toolTip.subTitle;
 
101
    argument.endStructure();
 
102
 
 
103
    return argument;
 
104
}
 
105
 
 
106
// Retrieve the ToolTipStruct data from the D-BUS argument
 
107
const QDBusArgument &operator>>(const QDBusArgument &argument, KDbusToolTipStruct &toolTip)
 
108
{
 
109
    QString icon;
 
110
    KDbusImageVector image;
 
111
    QString title;
 
112
    QString subTitle;
 
113
 
 
114
    if (argument.currentType() == QDBusArgument::StructureType) {
 
115
        argument.beginStructure();
 
116
        argument >> icon;
 
117
        argument >> image;
 
118
        argument >> title;
 
119
        argument >> subTitle;
 
120
        argument.endStructure();
 
121
    }
 
122
 
 
123
    toolTip.icon = icon;
 
124
    toolTip.image = image;
 
125
    toolTip.title = title;
 
126
    toolTip.subTitle = subTitle;
 
127
 
 
128
    return argument;
 
129
}