First commit master
authorRodrigo Vivi <rodrigo.vivi@collabora.co.uk>
Thu, 21 Oct 2010 17:27:57 +0000 (15:27 -0200)
committerRodrigo Vivi <rodrigo.vivi@collabora.co.uk>
Thu, 21 Oct 2010 17:27:57 +0000 (15:27 -0200)
Signed-off-by: Rodrigo Vivi <rodrigo.vivi@collabora.co.uk>

21 files changed:
debian/changelog [new file with mode: 0644]
debian/compat [new file with mode: 0644]
debian/control [new file with mode: 0644]
debian/hide-caller-id.install [new file with mode: 0644]
debian/rules [new file with mode: 0755]
hide-caller-id.desktop [new file with mode: 0644]
hide-caller-id.pro [new file with mode: 0644]
hide-caller-id.pro.user [new file with mode: 0644]
icons.qrc [new file with mode: 0644]
icons/hidden.png [new file with mode: 0644]
icons/shown.png [new file with mode: 0644]
qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.cpp [new file with mode: 0644]
qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.h [new file with mode: 0644]
qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.pri [new file with mode: 0644]
src/idwidget.cpp [new file with mode: 0644]
src/idwidget.h [new file with mode: 0644]
src/main.cpp [new file with mode: 0644]
src/testwidget.h [new file with mode: 0644]
src/tpsession.cpp [new file with mode: 0644]
src/tpsession.h [new file with mode: 0644]
welcome [deleted file]

diff --git a/debian/changelog b/debian/changelog
new file mode 100644 (file)
index 0000000..28f8adb
--- /dev/null
@@ -0,0 +1,5 @@
+hide-caller-id (0.0.1) unstable; urgency=low
+
+  * Initial Release.
+
+ -- Rodrigo Vivi <rodrigo.vivi@gmail.com>  Wed, 20 Oct 2010 16:11:16 -0200
diff --git a/debian/compat b/debian/compat
new file mode 100644 (file)
index 0000000..b8626c4
--- /dev/null
@@ -0,0 +1 @@
+4
diff --git a/debian/control b/debian/control
new file mode 100644 (file)
index 0000000..9964f4e
--- /dev/null
@@ -0,0 +1,12 @@
+Source: hide-caller-id
+Section: libs
+Priority: optional
+Maintainer: Rodrigo Vivi <rodrigo.vivi@collabora.co.uk>
+Build-Depends: libqt4-dev (>= 4.6.1), libhildon1-dev, libhildondesktop1-dev 
+Standards-Version: 3.7.3
+
+Package: hide-caller-id
+Architecture: any
+Section: devel
+Depends: libqt4-core (>= 4.6.1), libqt4-gui (>= 4.6.1), qt4-homescreen-loader
+Description: Hide Caller Id Homescreen Widget
diff --git a/debian/hide-caller-id.install b/debian/hide-caller-id.install
new file mode 100644 (file)
index 0000000..473ef24
--- /dev/null
@@ -0,0 +1,3 @@
+/usr/lib/hildon-desktop/hide-caller-id
+/usr/share/applications/hildon-home/hide-caller-id.desktop
+
diff --git a/debian/rules b/debian/rules
new file mode 100755 (executable)
index 0000000..72fe66a
--- /dev/null
@@ -0,0 +1,91 @@
+#!/usr/bin/make -f
+# -*- makefile -*-
+# Sample debian/rules that uses debhelper.
+# This file was originally written by Joey Hess and Craig Small.
+# As a special exception, when this file is copied by dh-make into a
+# dh-make output file, you may use that output file without restriction.
+# This special exception was added by Craig Small in version 0.37 of dh-make.
+
+# Uncomment this to turn on verbose mode.
+#export DH_VERBOSE=1
+
+
+
+
+
+configure: configure-stamp
+configure-stamp:
+       dh_testdir
+       # Add here commands to configure the package.
+
+       touch configure-stamp
+
+
+build: build-stamp
+
+build-stamp: configure-stamp  
+       dh_testdir
+
+       # Add here commands to compile the package.
+       $(MAKE)
+       #docbook-to-man debian/hide-caller-id.sgml > hide-caller-id.1
+
+       touch $@
+
+clean: 
+       dh_testdir
+       dh_testroot
+       rm -f build-stamp configure-stamp
+
+       # Add here commands to clean up after the build process.
+       $(MAKE) clean
+
+       dh_clean 
+
+install: build
+       dh_testdir
+       dh_testroot
+       dh_clean -k 
+       dh_installdirs
+
+       # Add here commands to install the package into debian/hide-caller-id
+       $(MAKE) INSTALL_ROOT="$(CURDIR)"/debian/hide-caller-id install
+
+
+# Build architecture-independent files here.
+binary-indep: build install
+# We have nothing to do by default.
+
+# Build architecture-dependent files here.
+binary-arch: build install
+       dh_testdir
+       dh_testroot
+       dh_installchangelogs 
+       dh_installdocs
+       dh_installexamples
+#      dh_install
+#      dh_installmenu
+#      dh_installdebconf       
+#      dh_installlogrotate
+#      dh_installemacsen
+#      dh_installpam
+#      dh_installmime
+#      dh_python
+#      dh_installinit
+#      dh_installcron
+#      dh_installinfo
+       dh_installman
+       dh_link
+       # dh_strip
+       dh_compress
+       dh_fixperms
+#      dh_perl
+#      dh_makeshlibs
+       dh_installdeb
+       # dh_shlibdeps
+       dh_gencontrol
+       dh_md5sums
+       dh_builddeb
+
+binary: binary-indep binary-arch
+.PHONY: build clean binary-indep binary-arch binary install configure
diff --git a/hide-caller-id.desktop b/hide-caller-id.desktop
new file mode 100644 (file)
index 0000000..d48de65
--- /dev/null
@@ -0,0 +1,11 @@
+[Desktop Entry]
+Name=Hide Caller Id
+Comment=Hide caller id home desktop item
+Type=qt
+X-Path=hide-caller-id
+X-Multiple-Instances=false
+X-home-applet-minwidth=100
+X-home-applet-minheight=72
+Name[en_US]=Hide Caller Id
+Exec=/usr/lib/hildon-desktop/hide-caller-id
+Icon=hide-caller-id
diff --git a/hide-caller-id.pro b/hide-caller-id.pro
new file mode 100644 (file)
index 0000000..3efb72d
--- /dev/null
@@ -0,0 +1,25 @@
+TEMPLATE = app
+
+SOURCES += src/main.cpp \
+    src/tpsession.cpp \
+    src/idwidget.cpp
+HEADERS += \
+    src/tpsession.h \
+    src/idwidget.h
+
+include(qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.pri)
+
+desktop.path = /usr/share/applications/hildon-home
+desktop.files = hide-caller-id.desktop
+
+target.path = /usr/lib/hildon-desktop
+INSTALLS += target desktop
+
+unix {
+INCLUDEPATH += /usr/include/telepathy-1.0
+INCLUDEPATH += /usr/include/QtDBus
+LIBS += -ltelepathy-qt4
+}
+
+RESOURCES += \
+    icons.qrc
diff --git a/hide-caller-id.pro.user b/hide-caller-id.pro.user
new file mode 100644 (file)
index 0000000..f3ac355
--- /dev/null
@@ -0,0 +1,189 @@
+<!DOCTYPE QtCreatorProject>
+<qtcreator>
+ <data>
+  <variable>ProjectExplorer.Project.ActiveTarget</variable>
+  <value type="int">0</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.EditorSettings</variable>
+  <valuemap type="QVariantMap">
+   <value key="EditorConfiguration.Codec" type="QByteArray">Default</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Target.0</variable>
+  <valuemap type="QVariantMap">
+   <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Maemo</value>
+   <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+   <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Target.MaemoDeviceTarget</value>
+   <value key="ProjectExplorer.Target.ActiveBuildConfiguration" type="int">0</value>
+   <value key="ProjectExplorer.Target.ActiveDeployConfiguration" type="int">0</value>
+   <value key="ProjectExplorer.Target.ActiveRunConfiguration" type="int">0</value>
+   <valuemap key="ProjectExplorer.Target.BuildConfiguration.0" type="QVariantMap">
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
+     <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+      <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+     </valuemap>
+     <valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+      <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+      <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+      <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+     </valuemap>
+     <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Build</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
+     <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+      <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+      <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+       <value type="QString">clean</value>
+      </valuelist>
+      <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+     </valuemap>
+     <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Clean</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
+    <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+    <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Release</value>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">0</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/vivijim/pessoal/hide-caller-id-build-maemo</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">8</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">9</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+   </valuemap>
+   <valuemap key="ProjectExplorer.Target.BuildConfiguration.1" type="QVariantMap">
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
+     <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">qmake</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">QtProjectManager.QMakeBuildStep</value>
+      <valuelist key="QtProjectManager.QMakeBuildStep.QMakeArguments" type="QVariantList"/>
+     </valuemap>
+     <valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+      <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">false</value>
+      <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList"/>
+      <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+     </valuemap>
+     <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Build</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Build</value>
+    </valuemap>
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.1" type="QVariantMap">
+     <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Make</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MakeStep</value>
+      <value key="Qt4ProjectManager.MakeStep.Clean" type="bool">true</value>
+      <valuelist key="Qt4ProjectManager.MakeStep.MakeArguments" type="QVariantList">
+       <value type="QString">clean</value>
+      </valuelist>
+      <value key="Qt4ProjectManager.MakeStep.MakeCommand" type="QString"></value>
+     </valuemap>
+     <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">1</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Clean</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Clean</value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">2</value>
+    <value key="ProjectExplorer.BuildConfiguration.ClearSystemEnvironment" type="bool">false</value>
+    <valuelist key="ProjectExplorer.BuildConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Debug</value>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.Qt4BuildConfiguration</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildConfiguration" type="int">2</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.BuildDirectory" type="QString">/home/vivijim/pessoal/hide-caller-id-build-maemo</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.QtVersionId" type="int">8</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.ToolChain" type="int">9</value>
+    <value key="Qt4ProjectManager.Qt4BuildConfiguration.UseShadowBuild" type="bool">true</value>
+   </valuemap>
+   <value key="ProjectExplorer.Target.BuildConfigurationCount" type="int">2</value>
+   <valuemap key="ProjectExplorer.Target.DeployConfiguration.0" type="QVariantMap">
+    <valuemap key="ProjectExplorer.BuildConfiguration.BuildStepList.0" type="QVariantMap">
+     <valuemap key="ProjectExplorer.BuildStepList.Step.0" type="QVariantMap">
+      <value key="Packaging Enabled" type="bool">true</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Packaging for Maemo</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MaemoPackageCreationStep</value>
+     </valuemap>
+     <valuemap key="ProjectExplorer.BuildStepList.Step.1" type="QVariantMap">
+      <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Deploy to Maemo device</value>
+      <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+      <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MaemoDeployStep</value>
+      <value key="Qt4ProjectManager.MaemoRunConfiguration.DeployToSysroot" type="bool">false</value>
+      <value key="Qt4ProjectManager.MaemoRunConfiguration.DeviceId" type="qulonglong">1</value>
+      <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedFiles" type="QVariantList">
+       <value type="QString">/home/vivijim/pessoal/hide-caller-id-build-maemo/hide-caller-id_0.0.1_armel.deb</value>
+      </valuelist>
+      <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedHosts" type="QVariantList">
+       <value type="QString">192.168.2.15</value>
+      </valuelist>
+      <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedRemotePaths" type="QVariantList">
+       <value type="QString"></value>
+      </valuelist>
+      <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.LastDeployedTimes" type="QVariantList">
+       <value type="QDateTime">2010-10-20T16:44:03</value>
+      </valuelist>
+     </valuemap>
+     <value key="ProjectExplorer.BuildStepList.StepsCount" type="int">2</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Deploy</value>
+     <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+     <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.BuildSteps.Deploy</value>
+    </valuemap>
+    <value key="ProjectExplorer.BuildConfiguration.BuildStepListCount" type="int">1</value>
+    <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">Deploy to Maemo device</value>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">ProjectExplorer.DefaultDeployConfiguration</value>
+   </valuemap>
+   <value key="ProjectExplorer.Target.DeployConfigurationCount" type="int">1</value>
+   <valuemap key="ProjectExplorer.Target.RunConfiguration.0" type="QVariantMap">
+    <value key="ProjectExplorer.ProjectConfiguration.DefaultDisplayName" type="QString">hide-caller-id</value>
+    <value key="ProjectExplorer.ProjectConfiguration.DisplayName" type="QString"></value>
+    <value key="ProjectExplorer.ProjectConfiguration.Id" type="QString">Qt4ProjectManager.MaemoRunConfiguration</value>
+    <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.Arguments" type="QVariantList"/>
+    <value key="Qt4ProjectManager.MaemoRunConfiguration.BaseEnvironmentBase" type="int">1</value>
+    <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.ExportedLocalDirs" type="QVariantList"/>
+    <value key="Qt4ProjectManager.MaemoRunConfiguration.ProFile" type="QString">hide-caller-id.pro</value>
+    <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.RemoteMountPoints" type="QVariantList"/>
+    <value key="Qt4ProjectManager.MaemoRunConfiguration.UseRemoteGdb" type="bool">false</value>
+    <valuelist key="Qt4ProjectManager.MaemoRunConfiguration.UserEnvironmentChanges" type="QVariantList"/>
+    <value key="RunConfiguration.QmlDebugServerPort" type="uint">3768</value>
+    <value key="RunConfiguration.UseCppDebugger" type="bool">true</value>
+    <value key="RunConfiguration.UseQmlDebugger" type="bool">false</value>
+   </valuemap>
+   <value key="ProjectExplorer.Target.RunConfigurationCount" type="int">1</value>
+  </valuemap>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.TargetCount</variable>
+  <value type="int">1</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.EnvironmentId</variable>
+  <value type="QString">{751d2bf9-42aa-4f49-99ea-c989cc8805f2}</value>
+ </data>
+ <data>
+  <variable>ProjectExplorer.Project.Updater.FileVersion</variable>
+  <value type="int">8</value>
+ </data>
+</qtcreator>
diff --git a/icons.qrc b/icons.qrc
new file mode 100644 (file)
index 0000000..d509e05
--- /dev/null
+++ b/icons.qrc
@@ -0,0 +1,6 @@
+<RCC>
+    <qresource prefix="/">
+        <file>icons/shown.png</file>
+        <file>icons/hidden.png</file>
+    </qresource>
+</RCC>
diff --git a/icons/hidden.png b/icons/hidden.png
new file mode 100644 (file)
index 0000000..fa2f3d0
Binary files /dev/null and b/icons/hidden.png differ
diff --git a/icons/shown.png b/icons/shown.png
new file mode 100644 (file)
index 0000000..68d6fd1
Binary files /dev/null and b/icons/shown.png differ
diff --git a/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.cpp b/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.cpp
new file mode 100644 (file)
index 0000000..ddd962d
--- /dev/null
@@ -0,0 +1,336 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmaemo5homescreenadaptor.h"
+
+#include <QtCore/qsocketnotifier.h>
+#include <QtCore/qpointer.h>
+
+#include <QtGui/qapplication.h>
+#include <QtGui/qx11info_x11.h>
+#include <QtGui/qwidget.h>
+#include <QtGui/qevent.h>
+
+#include <X11/Xlib.h>
+#include <X11/Xatom.h>
+#include <X11/Xutil.h>
+
+static QCoreApplication::EventFilter oldEventFilter;
+static QList<QMaemo5HomescreenAdaptor *> allDesktopItems;
+
+static Atom atomByName(const char *name)
+{
+    Atom atom = XInternAtom(QX11Info::display(), name, False);
+    if (!atom)
+        qWarning("Unable to obtain %s atom. This class requires a running Hildon session.", name);
+
+    return atom;
+}
+
+enum HomescreenAtoms
+{
+    HildonAppletId               = 0,
+    NetWmWindowType              = 1,
+    Utf8String                   = 2,
+    HildonTypeHomeApplet         = 3,
+    HildonAppletSettings         = 4,
+    HildonAppletShowSettings     = 5,
+    HildonAppletOnCurrentDesktop = 6,
+    EnumCount                    = 7
+};
+
+static Atom hsAtoms[EnumCount] = { 0, 0, 0, 0, 0, 0, 0 };
+
+static void initAtoms()
+{
+    hsAtoms[HildonAppletId] = atomByName("_HILDON_APPLET_ID");
+    hsAtoms[NetWmWindowType] = atomByName("_NET_WM_WINDOW_TYPE");
+    hsAtoms[Utf8String] = atomByName("UTF8_STRING");
+    hsAtoms[HildonTypeHomeApplet] = atomByName("_HILDON_WM_WINDOW_TYPE_HOME_APPLET");
+    hsAtoms[HildonAppletSettings] = atomByName("_HILDON_APPLET_SETTINGS");
+    hsAtoms[HildonAppletShowSettings] = atomByName("_HILDON_APPLET_SHOW_SETTINGS");
+    hsAtoms[HildonAppletOnCurrentDesktop] = atomByName("_HILDON_APPLET_ON_CURRENT_DESKTOP");
+}
+
+/*! \class QMaemo5HomescreenAdaptor
+
+    \brief The QMaemo5HomescreenAdaptor flags a top-level QWidget as homescreen widget
+
+    QMaemo5HomescreenAdaptor is used in conjunction with the Qt for Maemo homescreen
+    loader. It evaluates the two command line arguments "-plugin-id" and "-write-pipe"
+    to set up a Qt top-level widget as Maemo 5 homescreen widget.
+
+    Note: By default, the widget will have a black background. In order to make the
+    widget transparent, set the Qt::WA_TranslucentBackground widget attribute.
+
+    Example:
+
+    \code
+    QLabel *label = new QLabel("Hello Homescreen");
+    new QMaemo5HomescreenAdaptor(label);
+    label->show();
+    \endcode
+
+    Maemo 5 supports homescreen widgets with settings dialogs. To use it, set
+    the settingsAvailable() property and show a settings dialog when the
+    settingsRequested() signal is emitted.
+
+    Maemo 5 supports more than one homescreen. In order to determine whether
+    the homescreen widget is on the currently visible homescreen, connect to
+    the homescreenChanged() signal.
+*/
+
+/*! \property QMaemo5HomescreenAdaptor::settingsAvailable
+
+    Set this property to true if the widget can make use of a settings dialog,
+    otherwise to false. When this property is set to true, the Maemo 5 homescreen
+    renders a small settings icon on top of the homescreen widget when the
+    user enters the desktop menu. When the user clicks that settings icon, the
+    settingsRequested() signal is emitted.
+
+    The default is false.
+
+    \sa settingsRequested()
+ */
+
+/*! \fn void settingsRequested()
+
+    This signal is emitted every time the homescreen widget's settings icon is
+    invoked by the user. Note that this icon is only visible when the settingsAvailable()
+    property is set.
+
+    \sa settingsAvailable()
+ */
+
+/*! \fn void homescreenChanged(bool isOnCurrentHomescreen)
+
+    This is signal is emitted when current homescreen changes and the homescreen
+    widget becomes visible or invisible. The \a isOnCurrentHomescreen argument
+    indicates whether the homescreen widget is on the current homescreen or not.
+
+    This signal can be used to start/stop background processing in order to save
+    battery life.
+ */
+
+/*!
+    Constructs a new QMaemo5HomescreenAdaptor for the given \a widget.
+
+    Note: The widget must be a top-level widget, and must not be reparented
+    during the lifetime of this adaptor.
+
+    Note: \a widget is also the parent of this class, if the widget is destroyed,
+    so is this adaptor.
+ */
+QMaemo5HomescreenAdaptor::QMaemo5HomescreenAdaptor(QWidget *widget)
+    : QObject(widget),
+      hasSettings(false)
+{
+    Q_ASSERT(widget->isWindow());
+
+    if (!hsAtoms[0])
+        initAtoms();
+
+    Display *display = QX11Info::display();
+
+    const QStringList args = QApplication::arguments();
+
+    // parse the command line arguments.
+    int idx;
+    if ((idx = args.indexOf(QLatin1String("-plugin-id"))) != -1) {
+        appletId = args.value(idx + 1);
+        const QByteArray pluginId = appletId.toUtf8();
+        if (!pluginId.isEmpty()) {
+            XChangeProperty(display,
+                    widget->winId(),
+                    hsAtoms[HildonAppletId],
+                    hsAtoms[Utf8String], 8, PropModeReplace,
+                    reinterpret_cast<const unsigned char *>(pluginId.constData()),
+                    pluginId.length());
+        }
+    }
+    if ((idx = args.indexOf(QLatin1String("-write-pipe"))) != -1) {
+        bool ok;
+        int sockId = args.value(idx + 1).toInt(&ok);
+        if (ok) {
+            socketNotifier = new QSocketNotifier(sockId, QSocketNotifier::Exception, this);
+            connect(socketNotifier, SIGNAL(activated(int)), this, SLOT(socketException()));
+        }
+    }
+
+    // set the X11 atoms to flag our widget as homescreen widget
+    if (!appletId.isEmpty()) {
+        XChangeProperty(display,
+                widget->winId(),
+                hsAtoms[NetWmWindowType],
+                XA_ATOM, 32, PropModeReplace,
+                reinterpret_cast<const unsigned char *>(&hsAtoms[HildonTypeHomeApplet]),
+                1);
+
+        updateStatus();
+
+        // --- make this window a child of root
+        XSetTransientForHint(display, widget->winId(),
+                             RootWindow(display, widget->x11Info().screen()));
+
+        // --- add an x11 event filter
+        if (!oldEventFilter)
+            oldEventFilter = QCoreApplication::instance()->setEventFilter(applicationEventFilter);
+
+        allDesktopItems.append(this);
+
+        // --- set WM input hints indicating that we don't want focus events
+        XWMHints *h = XGetWMHints(display, widget->winId());
+        XWMHints wm_hints;
+        if (!h) {
+            memset(&wm_hints, 0, sizeof(wm_hints)); // make valgrind happy
+            h = &wm_hints;
+        }
+        h->flags |= InputHint;
+        h->input = False;
+
+        XSetWMHints(display, widget->winId(), h);
+        if (h != &wm_hints)
+            XFree(h);
+
+        widget->setMouseTracking(true);
+    }
+}
+
+QMaemo5HomescreenAdaptor::~QMaemo5HomescreenAdaptor()
+{
+    allDesktopItems.removeOne(this);
+}
+
+/*! \internal */
+void QMaemo5HomescreenAdaptor::updateStatus()
+{
+    if (appletId.isEmpty())
+        return;
+
+    Display *display = QX11Info::display();
+
+    // Set or remove settings property
+    if (hasSettings)
+        XChangeProperty(display,
+                appletWidget()->winId(),
+                hsAtoms[HildonAppletSettings],
+                XA_CARDINAL, 32, PropModeReplace,
+                (const unsigned char *) &(hasSettings), 1);
+    else
+        XDeleteProperty(display,
+                appletWidget()->winId(),
+                hsAtoms[HildonAppletSettings]);
+}
+
+/*! \internal */
+void QMaemo5HomescreenAdaptor::socketException()
+{
+    socketNotifier->setEnabled(false);
+    appletWidget()->close();
+}
+
+bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event)
+{
+    return QCoreApplication::sendSpontaneousEvent(receiver, event);
+}
+
+
+
+/*! \internal */
+bool QMaemo5HomescreenAdaptor::applicationEventFilter(void *message, long *result)
+{
+    static QPointer<QWidget> lastMouseWidget;
+    bool retval = false;
+
+    if (oldEventFilter)
+        retval = oldEventFilter(message, result);
+
+    if (allDesktopItems.isEmpty())
+        return retval;
+
+    XEvent *ev = reinterpret_cast<XEvent *>(message);
+
+    // Generate a mouse release for a leave Notify (as we don't get the mouse release from X11)
+    if (ev->type == ButtonPress) {
+        QPoint globalPos( ev->xbutton.x_root, ev->xbutton.y_root);
+        QWidget *widget = QWidget::find((WId)ev->xany.window);
+        if (widget) {
+            lastMouseWidget = widget->childAt(widget->mapFromGlobal(globalPos));
+            if (!lastMouseWidget)
+                lastMouseWidget = widget;
+        }
+
+    } else if (ev->type == ButtonRelease) {
+        lastMouseWidget = 0;
+
+    } else if (ev->type == LeaveNotify) {
+        if (lastMouseWidget) {
+            // create a mouse up event that lies in Nirvana.
+            QPoint pos(-1000, -1000);
+            QMouseEvent e(QEvent::MouseButtonRelease, pos, pos, Qt::LeftButton, Qt::NoButton, Qt::NoModifier);
+            qt_sendSpontaneousEvent(lastMouseWidget, &e);
+            lastMouseWidget = 0;
+       }
+
+    } else if (ev->type == ClientMessage) {
+        XClientMessageEvent *cm = (XClientMessageEvent *)message;
+        if (cm->message_type == hsAtoms[HildonAppletShowSettings]) {
+            for (int i = 0; i < allDesktopItems.count(); ++i) {
+                if (allDesktopItems.at(i)->appletWidget()->winId() == ev->xproperty.window) {
+                    emit allDesktopItems.at(i)->settingsRequested();
+                    retval = true;
+                }
+            }
+        }
+    } else if (ev->type == PropertyNotify) {
+        if (ev->xproperty.atom == hsAtoms[HildonAppletOnCurrentDesktop]) {
+            for (int i = 0; i < allDesktopItems.count(); ++i) {
+                if (allDesktopItems.at(i)->appletWidget()->winId() == ev->xproperty.window) {
+                    emit allDesktopItems.at(i)->homescreenChanged(ev->xproperty.window == 0);
+                    retval = true;
+                }
+            }
+        }
+    }
+
+    return retval;
+}
+
diff --git a/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.h b/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.h
new file mode 100644 (file)
index 0000000..9270649
--- /dev/null
@@ -0,0 +1,91 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef QMAEMO5HOMESCREENADAPTOR_H
+#define QMAEMO5HOMESCREENADAPTOR_H
+
+#include <QtCore/qobject.h>
+#include <QtCore/qpointer.h>
+#include <QtGui/qwidget.h>
+
+class QWidget;
+class QSocketNotifier;
+
+class QMaemo5HomescreenAdaptor : public QObject
+{
+    Q_OBJECT
+    Q_PROPERTY(bool settingsAvailable READ settingsAvailable WRITE setSettingsAvailable)
+
+public:
+    QMaemo5HomescreenAdaptor(QWidget *widget);
+    ~QMaemo5HomescreenAdaptor();
+
+    inline void setSettingsAvailable(bool available)
+    {
+        hasSettings = available;
+        updateStatus();
+    }
+
+    inline bool settingsAvailable() const
+    {
+        return hasSettings;
+    }
+
+Q_SIGNALS:
+    void settingsRequested();
+    void homescreenChanged(bool isOnCurrentHomescreen);
+
+private Q_SLOTS:
+    void socketException();
+
+private:
+    inline QWidget *appletWidget() const { return static_cast<QWidget *>(parent()); }
+
+    void updateStatus();
+
+    static bool applicationEventFilter(void *message, long *result);
+
+    bool hasSettings;
+    QString appletId;
+    QSocketNotifier *socketNotifier;
+};
+
+#endif
diff --git a/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.pri b/qmaemo5homescreenadaptor/qmaemo5homescreenadaptor.pri
new file mode 100644 (file)
index 0000000..73d41c3
--- /dev/null
@@ -0,0 +1,4 @@
+HEADERS += $$PWD/qmaemo5homescreenadaptor.h
+SOURCES += $$PWD/qmaemo5homescreenadaptor.cpp
+
+INCLUDEPATH += $$PWD
diff --git a/src/idwidget.cpp b/src/idwidget.cpp
new file mode 100644 (file)
index 0000000..08fac3f
--- /dev/null
@@ -0,0 +1,42 @@
+#include "idwidget.h"
+
+IdWidget::IdWidget(tpSession *tp)
+    : QPushButton()
+{
+    this->tp = tp;
+    setAttribute(Qt::WA_TranslucentBackground);
+    QObject::connect(this, SIGNAL(clicked()), this, SLOT(changeState()));
+    QObject::connect(tp, SIGNAL(privacyUpdated(bool)), this, SLOT(setButtonState(bool)));
+    pHidden = new QPixmap(":/icons/hidden.png");
+    pShown = new QPixmap(":/icons/shown.png");
+}
+
+void IdWidget::setButtonState(bool showId)
+{
+    QPixmap *pixmap;
+    this->showId = showId;
+
+    if(showId) {
+        pixmap = pShown;
+        setText("Id Shown");
+    }
+    else {
+        pixmap = pHidden;
+        setText("Id Hidden");
+    }
+
+    QIcon icon(*pixmap);
+    QSize iconSize(pixmap->width(), pixmap->height());
+    setIconSize(iconSize);
+    setIcon(icon);
+}
+
+void IdWidget::changeState()
+{
+    if(showId) {
+        tp->setPrivacy(false);
+    }
+    else {
+        tp->setPrivacy(true);
+    }
+}
diff --git a/src/idwidget.h b/src/idwidget.h
new file mode 100644 (file)
index 0000000..7e8840d
--- /dev/null
@@ -0,0 +1,45 @@
+#ifndef IDWIDGET_H
+#define IDWIDGET_H
+
+#include <QtGui/qpushbutton.h>
+#include <QtGui/qinputdialog.h>
+#include <QtGui/qpainter.h>
+#include "tpsession.h"
+
+class IdWidget : public QPushButton
+{
+    Q_OBJECT
+
+private:
+
+    bool showId;
+    tpSession *tp;
+    QPixmap *pHidden;
+    QPixmap *pShown;
+
+public:
+    IdWidget(tpSession *tp);
+
+    QSize sizeHint() const
+    {
+        return QSize(200, 75);
+    }
+
+public slots:
+    void changeState();
+    void setButtonState(bool showId);
+
+protected:
+    void paintEvent(QPaintEvent *event)
+    {
+        QPainter p(this);
+        p.setBrush(QColor(0, 0, 0, 128));
+        p.setPen(Qt::NoPen);
+        p.drawRoundedRect(rect(), 25, 25);
+        p.end();
+
+        QPushButton::paintEvent(event);
+    }
+};
+
+#endif
diff --git a/src/main.cpp b/src/main.cpp
new file mode 100644 (file)
index 0000000..fe54766
--- /dev/null
@@ -0,0 +1,56 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file was based on one of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include "qmaemo5homescreenadaptor.h"
+#include "idwidget.h"
+#include "tpsession.h"
+#include <QtGui>
+
+int main(int argc, char *argv[])
+{
+    QApplication app(argc, argv);
+    IdWidget *idWidget = new IdWidget(new tpSession());
+    QMaemo5HomescreenAdaptor *adaptor = new QMaemo5HomescreenAdaptor(idWidget);
+    adaptor->setSettingsAvailable(false);
+    idWidget->show();
+
+    app.exec();
+}
diff --git a/src/testwidget.h b/src/testwidget.h
new file mode 100644 (file)
index 0000000..0fadaff
--- /dev/null
@@ -0,0 +1,119 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the examples of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file.  Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights.  These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#ifndef IDWIDGET_H
+#define IDWIDGET_H
+
+#include <QtGui/qpushbutton.h>
+#include <QtGui/qinputdialog.h>
+#include <QtGui/qpainter.h>
+#include "tpsession.h"
+
+class IdWidget : public QPushButton
+{
+    Q_OBJECT
+
+public:
+
+    bool showId;
+    tpSession* tp;
+
+    IdWidget()
+        : QPushButton()
+    {
+        setAttribute(Qt::WA_TranslucentBackground);
+        QPixmap* pixmap = new QPixmap("/usr/share/vivi/shown.png");
+        showId = TRUE;
+        setText("Id Shown");
+        QIcon icon(*pixmap);
+        QSize iconSize(pixmap->width(), pixmap->height());
+        setIconSize(iconSize);
+        setIcon(icon);
+        QObject::connect(this, SIGNAL(clicked()), this, SLOT(changeState()));
+    }
+
+    IdWidget(tpSession tp)
+    {
+        this->tp = tp;
+    }
+
+    QSize sizeHint() const
+    {
+        return 1.2 * QPushButton::sizeHint();
+    }
+
+public slots:
+
+    void changeState()
+    {
+        QPixmap* pixmap;
+        if(showId) {
+            pixmap = new QPixmap("/usr/share/vivi/hidden.png");
+            showId = FALSE;
+            setText("Id Hidden");
+            tp->setPrivacy(true);
+        }
+        else {
+            pixmap = new QPixmap("/usr/share/vivi/shown.png");
+            showId = TRUE;
+            setText("Id Shown");
+            tp->setPrivacy(false);
+        }
+        QIcon icon(*pixmap);
+        QSize iconSize(pixmap->width(), pixmap->height());
+        setIconSize(iconSize);
+        setIcon(icon);
+    }
+
+protected:
+    void paintEvent(QPaintEvent *event)
+    {
+        QPainter p(this);
+        p.setBrush(QColor(0, 0, 0, 128));
+        p.setPen(Qt::NoPen);
+        p.drawRoundedRect(rect(), 25, 25);
+        p.end();
+
+        QPushButton::paintEvent(event);
+    }
+};
+
+#endif
diff --git a/src/tpsession.cpp b/src/tpsession.cpp
new file mode 100644 (file)
index 0000000..5ad4311
--- /dev/null
@@ -0,0 +1,147 @@
+#include "tpsession.h"
+
+#include <TelepathyQt4/Account>
+#include <TelepathyQt4/AccountInterface>
+#include <TelepathyQt4/PendingOperation>
+#include <TelepathyQt4/PendingVoid>
+#include <TelepathyQt4/PendingReady>
+#include <QtDBus/QDBusPendingCallWatcher>
+#include <QtDBus/QDBusPendingReply>
+
+tpSession::tpSession()
+{
+    QDBusConnection bus = QDBusConnection::sessionBus();
+    mAM = AccountManager::create(bus,
+                                 AccountFactory::create(bus, Account::FeatureCore),
+                                 ConnectionFactory::create(bus, Connection::FeatureCore),
+                                 ChannelFactory::create(bus));
+
+    connect(mAM->becomeReady(),
+            SIGNAL(finished(Tp::PendingOperation *)),
+            SLOT(onAMReady(Tp::PendingOperation *)));
+}
+
+void tpSession::onAMReady(Tp::PendingOperation *op)
+{
+    if (op->isError()) {
+        qWarning() << "error making AM ready";
+        return;
+    }
+
+    mAccount = mAM->accountForPath("/org/freedesktop/Telepathy/Account/ring/tel/ring");
+    if (!mAccount) {
+        qWarning() << "no account for ring found";
+        return;
+    }
+
+    //connect(mAccount->baseInterface(), SIGNAL(AccountPropertyChanged(const QVariantMap&)), this, SLOT(onPrivacyChanged(const QVariantMap&)));
+    if (!mAccount->haveConnection()) {
+        connect(mAccount.data(),
+                SIGNAL(haveConnectionChanged(bool)),
+                SLOT(onAccountHaveConnectionChanged(bool)));
+    } else {
+        mConnection = mAccount->connection();
+        retrievePrivacy();
+    }
+}
+
+void tpSession::onPropertyChanged(const QVariantMap& properties)
+{
+     qDebug() << "TODO: change state when Privacy has been updated by someone else" << properties;
+}
+
+void tpSession::onAccountHaveConnectionChanged(bool haveConnection)
+{
+    if (haveConnection) {
+        mConnection = mAccount->connection();
+        retrievePrivacy();
+    }
+}
+
+void tpSession::onSetPrivacyFinished(Tp::PendingOperation *op)
+{
+    if (op->isError()) {
+        qWarning() << "unable to set com.nokia.Telepathy.Connection.Interface.GSM.Privacy";
+        return;
+    }
+
+    qDebug() << "com.nokia.Telepathy.Connection.Interface.GSM.Privacy property set";
+    emit privacyUpdated(showId);
+}
+
+void tpSession::onGotPrivacy(QDBusPendingCallWatcher *watcher)
+{
+    QDBusPendingReply<QVariant> reply = *watcher;
+
+    if (reply.isError()) {
+        qWarning() << "unable to get com.nokia.Telepathy.Connection.Interface.GSM.Privacy";
+        return;
+    }
+
+    // Don't ask me why, but no-id == showId and id == hide it.
+    if(qdbus_cast<QStringList>(reply.value()) == QVariant("no-id"))
+        showId = true;
+    else
+        showId = false;
+    emit privacyUpdated(showId);
+
+    qDebug() << "com.nokia.Telepathy.Connection.Interface.GSM.Privacy property set";
+}
+
+void tpSession::retrievePrivacy()
+{
+    if (!mConnection) {
+        qWarning() << "Account Manager connection unavailable";
+        return;
+    }
+
+    if (!mConnection->hasInterface("com.nokia.Telepathy.Connection.Interface.GSM")) {
+        qWarning() << "connection does not have interface GSM";
+        return;
+    }
+
+    QDBusPendingCallWatcher *watcher = new QDBusPendingCallWatcher(
+                mConnection->propertiesInterface()->Get(
+                    QLatin1String("com.nokia.Telepathy.Connection.Interface.GSM"),
+                    QLatin1String("Privacy")), this);
+
+    connect(watcher,
+            SIGNAL(finished(QDBusPendingCallWatcher *)),
+            SLOT(onGotPrivacy(QDBusPendingCallWatcher *)));
+
+    qDebug() << "com.nokia.Telepathy.Connection.Interface.GSM.Privacy retrieved";
+}
+
+void tpSession::setPrivacy(bool value)
+{
+    showId = value;
+
+    if (!mConnection) {
+        qWarning() << "Account Manager connection unavailable";
+        return;
+    }
+
+    if (!mConnection->hasInterface("com.nokia.Telepathy.Connection.Interface.GSM")) {
+        qWarning() << "connection does not have interface GSM";
+        return;
+    }
+
+    PendingVoid *call;
+    // Don't ask me why, but no-id == showId and id == hide it.
+    if(value)
+        call = new PendingVoid(
+                    mConnection->propertiesInterface()->Set(
+                        QLatin1String("com.nokia.Telepathy.Connection.Interface.GSM"),
+                        QLatin1String("Privacy"), QDBusVariant("no-id")),
+                    this);
+    else
+        call = new PendingVoid(
+                    mConnection->propertiesInterface()->Set(
+                        QLatin1String("com.nokia.Telepathy.Connection.Interface.GSM"),
+                        QLatin1String("Privacy"), QDBusVariant("id")),
+                    this);
+
+    connect(call,
+            SIGNAL(finished(Tp::PendingOperation*)),
+            SLOT(onSetPrivacyFinished(Tp::PendingOperation*)));
+}
diff --git a/src/tpsession.h b/src/tpsession.h
new file mode 100644 (file)
index 0000000..9281e13
--- /dev/null
@@ -0,0 +1,36 @@
+#ifndef TPSESSION_H
+#define TPSESSION_H
+
+#include <QObject>
+#include <TelepathyQt4/AccountManager>
+
+using namespace Tp;
+
+class tpSession : public QObject
+{
+    Q_OBJECT
+
+public:
+    tpSession();
+    ~tpSession() {}
+    void setPrivacy(bool showId);
+    void retrievePrivacy();
+
+private Q_SLOTS:
+    void onAMReady(Tp::PendingOperation *op);
+    void onAccountHaveConnectionChanged(bool value);
+    void onSetPrivacyFinished(Tp::PendingOperation *op);
+    void onGotPrivacy(QDBusPendingCallWatcher *op);
+    void onPropertyChanged(const QVariantMap& properties);
+
+private:
+    AccountManagerPtr mAM;
+    AccountPtr mAccount;
+    ConnectionPtr mConnection;
+    bool showId;
+
+signals:
+    void privacyUpdated(bool showId);
+};
+
+#endif // TPSESSION_H
diff --git a/welcome b/welcome
deleted file mode 100644 (file)
index e69de29..0000000