summaryrefslogtreecommitdiff
path: root/ertyo.tex
blob: 35eccda4dfc8c7e516f9b2c120a45d6fe645ad37 (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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
% vim: set nocin noai nosmartindent:
\documentclass[11pt,a4paper]{article}
\usepackage{ucs}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{txfonts}
\usepackage{url}
\usepackage[american]{babel}
\usepackage[pdftex]{color,graphicx}
\usepackage{scrpage2}
\usepackage[onehalfspacing]{setspace}

% UTU compliant page layout

\addtolength{\voffset}{-1.8cm}
\addtolength{\textheight}{2.8cm}
\addtolength{\footskip}{6mm}
\addtolength{\hoffset}{-2cm}
\setlength{\textwidth}{17cm}

\ifoot[]{}
\cfoot[]{}
\ofoot[\small\pagemark]{\pagemark}
\setlength{\headheight}{1.3\baselineskip}

\begin{document}

\begin{titlepage}
\begingroup

\begin{singlespace}

\begin{center}
\vspace*{7.3cm}
\hrule
\vspace{.7cm}
\Large \textbf{Master's project}
\vspace{.7cm}
\hrule
\end{center}

\vspace{\stretch{1}}
\begin{flushright}
\begin{minipage}{0.45\textwidth}
\begin{flushright}
\small
UNIVERSITY OF TURKU \\
\mbox{Department of Information Technology} \\
\mbox{Computer Science} \\
\today \\
Olli Salli \\
\end{flushright}
\end{minipage}
\end{flushright}
\vspace{\stretch{0}}

\end{singlespace}

\endgroup
\end{titlepage}

% Table of Contents

\selectlanguage{american}

\clearpage

\tableofcontents

% Text chapters

\section{Introduction}

The topic of my Master's thesis\footnote{\url{http://urn.fi/URN:NBN:fi-fe201208246345}} is
``Building object-oriented software with the D-Bus messaging system''. D-Bus is a message
passing-oriented inter-process communication (IPC) system. The focus of the thesis is on practical
requirements on how D-Bus and similar systems can be used in interactive desktop software. Several
object-oriented design and implementation techniques that help creating software fulfilling these
requirements are presented and analyzed.

The ideas presented in the thesis are based on my work on the open-source Telepathy communications
framework\footnote{\url{http://telepathy.freedesktop.org}}. Telepathy consists of independent
modules such as protocol backends, account storage and logging services, and user interfaces (UIs).
The modules are connected together at runtime over the D-Bus messaging bus.

Over the year, the various components of Telepathy have been contributed to by dozens of people.
This report details those of my own personal contributions that are directly connected with the
thesis.

\section{Early backend and interface design work}

My involvement with Telepathy started in 2006 with implementing the \texttt{te\-le\-pa\-thy-id\-le}
protocol backend for the Internet Relay Chat (IRC) protocol. At that point, Telepathy was in its
infancy, with only one other reasonably complete protocol backend in existence, one for the
Jabber/XMPP protocol. Telepathy was being taken into use in a software update for the Nokia 770
Internet Tablet device, which had a slow 200 MHz ARM CPU and only 128 megabytes of RAM.

Section 5.5 of the thesis deals with mechanisms that allow querying the state of multiple objects
with one D-Bus method call. When I started working on \texttt{te\-le\-pa\-thy-id\-le}, these
mechanisms didn't exist yet in Telepathy. IRC chat rooms can have thousands of members, which used
to cause several thousand D-Bus method calls to be made to the protocol backend. With the limited
resources of the Nokia 770, joining an IRC chat room could thus take minutes. In version 0.13 of the
Telepathy D-Bus interfaces,\footnote{\url{http://telepathy.freedesktop.org/spec-0.13.html}} we
changed all operations that worked with contacts to process an arbitrary number of contacts with a
single call. This improved the performance of Telepathy with IRC to a reasonable level.

Initially, \texttt{telepathy-idle} exposed its functionality over D-Bus by implementing low-level
stub methods. These stubs were generated from low-level D-Bus introspection data corresponding to
the Telepathy D-Bus interfaces. As detailed in Section 6.1 of the thesis, this format lacks
sufficient information for meaningful static typing of more complex method arguments. For this
reason, a lot of hand-written code was required in \texttt{te\-le\-pa\-thy-id\-le} for the purpose
of encoding and decoding argument values. Because it implemented the same interfaces, similar code
was also required in the Telepathy XMPP protocol backend. Over time, we refactored these and some
other common pieces of the implementation to the \texttt{te\-le\-pa\-thy-glib} library, and in
May 2007 I completed reimplementing the IRC backend using the
library\footnote{\url{http://lists.freedesktop.org/archives/telepathy/2007-May/000677.html}}.

\section{UI-side work}

After \texttt{telepathy-idle}, I implemented another Telepathy backend for a proprietary protocol
using the \texttt{te\-le\-pa\-thy-glib} library. At this point, Telepathy was used in a fairly
complex setting in the Nokia N800 and N810 devices, successors to the original 770. As a part of
this work, I investigated some issues with the device freezing in certain communication situations.
This was caused by certain UI-side Telepathy-related components calling D-Bus methods on each
other using the pseudo-blocking algorithm, forming a \emph{wait-reorder cycle}, as explained in
Section~3.5.3 of the thesis.

In Summer 2008, I
started\footnote{\url{http://cgit.freedesktop.org/telepathy/telepathy-qt/commit/?id=190ecb3d7cd80732d1cd8dc484184a8cfe104707}}
the \texttt{te\-le\-pa\-thy-qt4} project to enable implementing Telepathy UIs using the Qt framework
more easily. This was motivated by Nokia acquiring Trolltech, the developer of
Qt,\footnote{\url{http://press.nokia.com/2008/01/28/nokia-to-acquire-trolltech-to-accelerate-software-strategy/}}
and eventual rebasing of their Linux device portfolio on Qt. The library later became the basis for
all messaging-related components in the Harmattan release of their Maemo/MeeGo operating system,
used in the Nokia N9 mobile phone, and a part of its
SDK.\footnote{\url{http://harmattan-dev.nokia.com/docs/library/html/libtelepathy-qt4-1-doc/main.html}}

\subsection{Code generation}

As the first part of the \texttt{tp-qt4} project, I implemented machinery to generate low-level
proxy code for accessing Telepathy service objects. This is at the level described by Section~6.2 of
the thesis.

At that point, the Telepathy D-Bus interfaces were no longer specified using the bare D-Bus
introspection format, but an extended version. However, due to differences between the GLib and Qt
type systems, some further modifications were required to generate Qt code.\footnote{
\url{http://cgit.freedesktop.org/telepathy/telepathy-spec/log/?id=657342595d19196e7dd00595f754f039796f52f8}}
To facilitate these, and to enable sharing some parts of the machinery between \texttt{tp-qt4} and
\texttt{tp-glib}, I also partially reimplemented the \texttt{te\-le\-pa\-thy-glib} code generation
machinery.\footnote{e.g.~\url{http://lists.freedesktop.org/archives/telepathy-commits/2008-May/000827.html}}

Owing to experience from previous projects, from the start, the generated \texttt{tp-qt4} proxies
have only made it possible to call methods asynchronously. At the lowest level, the calls are
represented using \texttt{QD\-Bus\-Pen\-ding\-Call\-Wat\-cher} objects from the Qt framework.

\subsection{Higher-level proxies}

Generated proxies follow the structure of the D-Bus API, for which the prime concern is
flexibility and efficiency. This occasionally makes the APIs less convenient to use. For this
reason, both \texttt{tp-qt4} and \texttt{tp-glib} wrap the generated proxies with a hand-written
higher-level API, as described in the introduction to Chapter 6 of the thesis. I implemented the
\texttt{tp-qt4} high-level proxies together with Andre Magalhaes and Simon McVittie, among others.

Up to 2010, we were busy implementing basic state caching proxies (thesis section~5.2) for all parts
of the Telepathy API, and following changes to the other parts of the framework. Because the
primary target platform of \texttt{tp-qt4} was a mobile phone, special attention was paid to
avoiding redundant battery-eating wakeups. One artifact of this is the conditional activation
functionality in the state caching mechanism, described in Section~5.3 of the thesis as the
``Optional Proxy Features'' pattern.

Another notable feature of the proxies in \texttt{tp-qt4} is wrapping some D-Bus operations inside
higher level ``job objects''. These are described as the ``Pending Operation Objects'' and
``Composite Pending Operation'' patterns in Section~5.1 of the thesis. One example is the
facility for fetching contact information from a protocol backend, using the D-Bus level
mechanisms described in Section~5.5 of the thesis. The efficiency orientation of these mechanisms
make them very inconvenient to use directly. For this reason, they are wrapped as pending operations
in the \texttt{Con\-tact\-Ma\-na\-ger} part of the \texttt{tp-qt4} API, which I implemented in early
2009.\footnote{\url{http://cgit.freedesktop.org/telepathy/telepathy-qt/log/?id=d86579e34367641c4b2ca23096791950bf9fa72c}}

% 5.4 factories
% - lots of features, prepare separately, blah blah, hard
% https://bugs.freedesktop.org/show_bug.cgi?id=29451 (general "it's hard")
% https://bugs.freedesktop.org/show_bug.cgi?id=29606 (acc/conn fact.)

% 5.5 multiplexed state sync
% - early 2009: implemented tp-qt4 Contact, ContactManager with Conn.I.Contacts D-Bus API

\end{document}