Added qmafw-gst-subtitles-renderer-0.0.55 for Meego Harmattan 1.2
[mafwsubrenderer] / qmafw-gst-subtitles-renderer / unittests / ut_MafwGstRenderer / ContextFWStub.cpp
1 /*
2  * This file is part of QMAFW
3  *
4  * Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). All rights
5  * reserved.
6  *
7  * Contact: Visa Smolander <visa.smolander@nokia.com>
8  *
9  * This software, including documentation, is protected by copyright controlled
10  * by Nokia Corporation. All rights are reserved. Copying, including
11  * reproducing, storing, adapting or translating, any or all of this material
12  * requires the prior written consent of Nokia Corporation. This material also
13  * contains confidential information which may not be disclosed to others
14  * without the prior written consent of Nokia.
15  *
16  */
17
18 #include <contextsubscriber/contextproperty.h>
19 #include <contextsubscriber/contextproviderinfo.h>
20 #include <contextsubscriber/contextpropertyinfo.h>
21 #include <sys/creds.h>
22 #include <QDebug>
23 #include <QDBusConnectionInterface>
24
25 ContextProperty *global_video_route_property = 0;
26 ContextProperty *global_audio_route_property = 0;
27 QString global_audio_route("");
28 QString global_video_route("");
29 ContextPropertyInfo propertyInfo("key");
30
31 ContextProperty::ContextProperty(const QString& key, QObject*)
32 {
33     if (key == "/com/nokia/policy/video_route" && global_video_route_property == 0)
34     {
35         global_video_route_property = this;
36     }
37     else if (key == "/com/nokia/policy/audio_route" && global_audio_route_property == 0)
38     {
39         global_audio_route_property = this;
40     }
41 }
42
43 ContextProperty::~ContextProperty()
44 {
45     qDebug() << __PRETTY_FUNCTION__;
46     if (this == global_video_route_property)
47     {
48         global_video_route_property = 0;
49     }
50     else if (this == global_audio_route_property)
51     {
52         global_audio_route_property = 0;
53     }
54 }
55
56 // this non-const function is used to trigger the signal emissions
57 void ContextProperty::ignoreCommander()
58 {
59     Q_EMIT global_video_route_property->valueChanged();
60     Q_EMIT global_audio_route_property->valueChanged();
61 }
62
63 QString ContextProperty::key() const
64 {
65     if (this == global_video_route_property)
66     {
67         return "/com/nokia/policy/video_route";
68     }
69     else if (this == global_audio_route_property)
70     {
71         return "/com/nokia/policy/audio_route";
72     }
73     else
74     {
75         return  "";
76     }
77 }
78
79 QVariant ContextProperty::value() const
80 {
81     if (this == global_video_route_property)
82     {
83         return QVariant(global_video_route);
84     }
85     else if (this == global_audio_route_property)
86     {
87         return QVariant(global_audio_route);
88     }
89     else
90     {
91         return  QVariant();
92     }
93 }
94
95 const ContextPropertyInfo* ContextProperty::info() const
96 {
97     return &propertyInfo;
98 }
99
100 ContextPropertyInfo::ContextPropertyInfo(const QString &key, QObject *parent)
101 {
102     Q_UNUSED(key);
103     Q_UNUSED(parent);
104 }
105
106 const QList<ContextProviderInfo> ContextPropertyInfo::providers() const
107 {
108     QList<ContextProviderInfo> list;
109     list << ContextProviderInfo("contextkit-dbus", "system:com.nokia.policy.pcfd");
110     return list;
111 }
112
113 // d-bus stub
114 bool QDBusError::isValid() const
115 {
116     return false;
117 }
118
119 QDBusMessage::MessageType QDBusMessage::type() const
120 {
121     if( this->member()=="GetConnectionUnixProcessID" )
122     {
123         return QDBusMessage::ReplyMessage;
124     }
125
126     return QDBusMessage::SignalMessage;
127 }