aboutsummaryrefslogtreecommitdiff
path: root/doc/context-arch.html
blob: 29e6df34fda5682b3a6f629c8b9cf6b996284ccb (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
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
    "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="generator" content="AsciiDoc 8.4.4" />
<title>Context Framework Subsystem Architecture Description</title>
<style type="text/css">
/* Debug borders */
p, li, dt, dd, div, pre, h1, h2, h3, h4, h5, h6 {
/*
  border: 1px solid red;
*/
}

body {
  margin: 1em 5% 1em 5%;
}

a {
  color: blue;
  text-decoration: underline;
}
a:visited {
  color: fuchsia;
}

em {
  font-style: italic;
  color: navy;
}

strong {
  font-weight: bold;
  color: #083194;
}

tt {
  color: navy;
}

h1, h2, h3, h4, h5, h6 {
  color: #527bbd;
  font-family: sans-serif;
  margin-top: 1.2em;
  margin-bottom: 0.5em;
  line-height: 1.3;
}

h1, h2, h3 {
  border-bottom: 2px solid silver;
}
h2 {
  padding-top: 0.5em;
}
h3 {
  float: left;
}
h3 + * {
  clear: left;
}

div.sectionbody {
  font-family: serif;
  margin-left: 0;
}

hr {
  border: 1px solid silver;
}

p {
  margin-top: 0.5em;
  margin-bottom: 0.5em;
}

ul, ol, li > p {
  margin-top: 0;
}

pre {
  padding: 0;
  margin: 0;
}

span#author {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  font-size: 1.1em;
}
span#email {
}
span#revision {
  font-family: sans-serif;
}

div#footer {
  font-family: sans-serif;
  font-size: small;
  border-top: 2px solid silver;
  padding-top: 0.5em;
  margin-top: 4.0em;
}
div#footer-text {
  float: left;
  padding-bottom: 0.5em;
}
div#footer-badges {
  float: right;
  padding-bottom: 0.5em;
}

div#preamble {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.tableblock, div.imageblock, div.exampleblock, div.verseblock,
div.quoteblock, div.literalblock, div.listingblock, div.sidebarblock,
div.admonitionblock {
  margin-top: 1.5em;
  margin-bottom: 1.5em;
}
div.admonitionblock {
  margin-top: 2.5em;
  margin-bottom: 2.5em;
}

div.content { /* Block element content. */
  padding: 0;
}

/* Block element titles. */
div.title, caption.title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  text-align: left;
  margin-top: 1.0em;
  margin-bottom: 0.5em;
}
div.title + * {
  margin-top: 0;
}

td div.title:first-child {
  margin-top: 0.0em;
}
div.content div.title:first-child {
  margin-top: 0.0em;
}
div.content + div.title {
  margin-top: 0.0em;
}

div.sidebarblock > div.content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}

div.listingblock > div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock {
  padding-left: 2.0em;
  margin-right: 10%;
}
div.quoteblock > div.attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock {
  padding-left: 2.0em;
  margin-right: 10%;
}
div.verseblock > div.content {
  white-space: pre;
}
div.verseblock > div.attribution {
  padding-top: 0.75em;
  text-align: left;
}
/* DEPRECATED: Pre version 8.2.7 verse style literal block. */
div.verseblock + div.attribution {
  text-align: left;
}

div.admonitionblock .icon {
  vertical-align: top;
  font-size: 1.1em;
  font-weight: bold;
  text-decoration: underline;
  color: #527bbd;
  padding-right: 0.5em;
}
div.admonitionblock td.content {
  padding-left: 0.5em;
  border-left: 2px solid silver;
}

div.exampleblock > div.content {
  border-left: 2px solid silver;
  padding: 0.5em;
}

div.imageblock div.content { padding-left: 0; }
div.imageblock img { border: 1px solid silver; }
span.image img { border-style: none; }

dl {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
dt {
  margin-top: 0.5em;
  margin-bottom: 0;
  font-style: normal;
  color: navy;
}
dd > *:first-child {
  margin-top: 0.1em;
}

ul, ol {
    list-style-position: outside;
}
ol.arabic {
  list-style-type: decimal;
}
ol.loweralpha {
  list-style-type: lower-alpha;
}
ol.upperalpha {
  list-style-type: upper-alpha;
}
ol.lowerroman {
  list-style-type: lower-roman;
}
ol.upperroman {
  list-style-type: upper-roman;
}

div.compact ul, div.compact ol,
div.compact p, div.compact p,
div.compact div, div.compact div {
  margin-top: 0.1em;
  margin-bottom: 0.1em;
}

div.tableblock > table {
  border: 3px solid #527bbd;
}
thead {
  font-family: sans-serif;
  font-weight: bold;
}
tfoot {
  font-weight: bold;
}
td > div.verse {
  white-space: pre;
}
p.table {
  margin-top: 0;
}
/* Because the table frame attribute is overriden by CSS in most browsers. */
div.tableblock > table[frame="void"] {
  border-style: none;
}
div.tableblock > table[frame="hsides"] {
  border-left-style: none;
  border-right-style: none;
}
div.tableblock > table[frame="vsides"] {
  border-top-style: none;
  border-bottom-style: none;
}


div.hdlist {
  margin-top: 0.8em;
  margin-bottom: 0.8em;
}
div.hdlist tr {
  padding-bottom: 15px;
}
dt.hdlist1.strong, td.hdlist1.strong {
  font-weight: bold;
}
td.hdlist1 {
  vertical-align: top;
  font-style: normal;
  padding-right: 0.8em;
  color: navy;
}
td.hdlist2 {
  vertical-align: top;
}
div.hdlist.compact tr {
  margin: 0;
  padding-bottom: 0;
}

.comment {
  background: yellow;
}

@media print {
  div#footer-badges { display: none; }
}

div#toctitle {
  color: #527bbd;
  font-family: sans-serif;
  font-size: 1.1em;
  font-weight: bold;
  margin-top: 1.0em;
  margin-bottom: 0.1em;
}

div.toclevel1, div.toclevel2, div.toclevel3, div.toclevel4 {
  margin-top: 0;
  margin-bottom: 0;
}
div.toclevel2 {
  margin-left: 2em;
  font-size: 0.9em;
}
div.toclevel3 {
  margin-left: 4em;
  font-size: 0.9em;
}
div.toclevel4 {
  margin-left: 6em;
  font-size: 0.9em;
}
/* Workarounds for IE6's broken and incomplete CSS2. */

div.sidebar-content {
  background: #ffffee;
  border: 1px solid silver;
  padding: 0.5em;
}
div.sidebar-title, div.image-title {
  color: #527bbd;
  font-family: sans-serif;
  font-weight: bold;
  margin-top: 0.0em;
  margin-bottom: 0.5em;
}

div.listingblock div.content {
  border: 1px solid silver;
  background: #f4f4f4;
  padding: 0.5em;
}

div.quoteblock-attribution {
  padding-top: 0.5em;
  text-align: right;
}

div.verseblock-content {
  white-space: pre;
}
div.verseblock-attribution {
  padding-top: 0.75em;
  text-align: left;
}

div.exampleblock-content {
  border-left: 2px solid silver;
  padding-left: 0.5em;
}

/* IE6 sets dynamically generated links as visited. */
div#toc a:visited { color: blue; }
</style>
<script type="text/javascript">
/*<![CDATA[*/
window.onload = function(){generateToc(2)}
/* Author: Mihai Bazon, September 2002
 * http://students.infoiasi.ro/~mishoo
 *
 * Table Of Content generator
 * Version: 0.4
 *
 * Feel free to use this script under the terms of the GNU General Public
 * License, as long as you do not remove or alter this notice.
 */

 /* modified by Troy D. Hanson, September 2006. License: GPL */
 /* modified by Stuart Rackham, October 2006. License: GPL */

function getText(el) {
  var text = "";
  for (var i = el.firstChild; i != null; i = i.nextSibling) {
    if (i.nodeType == 3 /* Node.TEXT_NODE */) // IE doesn't speak constants.
      text += i.data;
    else if (i.firstChild != null)
      text += getText(i);
  }
  return text;
}

function TocEntry(el, text, toclevel) {
  this.element = el;
  this.text = text;
  this.toclevel = toclevel;
}

function tocEntries(el, toclevels) {
  var result = new Array;
  var re = new RegExp('[hH]([2-'+(toclevels+1)+'])');
  // Function that scans the DOM tree for header elements (the DOM2
  // nodeIterator API would be a better technique but not supported by all
  // browsers).
  var iterate = function (el) {
    for (var i = el.firstChild; i != null; i = i.nextSibling) {
      if (i.nodeType == 1 /* Node.ELEMENT_NODE */) {
        var mo = re.exec(i.tagName)
        if (mo)
          result[result.length] = new TocEntry(i, getText(i), mo[1]-1);
        iterate(i);
      }
    }
  }
  iterate(el);
  return result;
}

// This function does the work. toclevels = 1..4.
function generateToc(toclevels) {
  var toc = document.getElementById("toc");
  var entries = tocEntries(document.getElementsByTagName("body")[0], toclevels);
  for (var i = 0; i < entries.length; ++i) {
    var entry = entries[i];
    if (entry.element.id == "")
      entry.element.id = "toc" + i;
    var a = document.createElement("a");
    a.href = "#" + entry.element.id;
    a.appendChild(document.createTextNode(entry.text));
    var div = document.createElement("div");
    div.appendChild(a);
    div.className = "toclevel" + entry.toclevel;
    toc.appendChild(div);
  }
  if (entries.length == 0)
    document.getElementById("header").removeChild(toc);
}
/*]]>*/
</script>
</head>
<body>
<div id="header">
<h1>Context Framework Subsystem Architecture Description</h1>
<div id="toc">
  <div id="toctitle">Table of Contents</div>
  <noscript><p><b>JavaScript must be enabled in your browser to display the table of contents.</b></p></noscript>
</div>
</div>
<div id="preamble">
<div class="sectionbody">
<div class="tableblock">
<table rules="all"
width="30%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="50%" />
<col width="50%" />
<tbody>
<tr>
<td align="left" valign="top"><p class="table">Author</p></td>
<td align="left" valign="top"><p class="table">Marius Vollmer</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Status</p></td>
<td align="left" valign="top"><p class="table">Draft</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Version</p></td>
<td align="left" valign="top"><p class="table">2009-11-18</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">Approver</p></td>
<td align="left" valign="top"><p class="table">Olli Finni</p></td>
</tr>
</tbody>
</table>
</div>
<div class="paragraph"><p>Copyright &#169; Nokia.  All rights reserved.</p></div>
<div class="paragraph"><p>This material, including documentation and any related computer
programs, is protected by copyright controlled by Nokia. All rights
are reserved. Copying, including reproducing, storing, adapting or
translating, any or all of this material requires the prior written
consent of Nokia. This material also contains confidential
information, which may not be disclosed to others without the prior
written consent of Nokia.</p></div>
<div class="paragraph"><p>Nokia is a registered trademark of Nokia. Other company and product
names mentioned herein may be trademarks or tradenames of their
respective owners.</p></div>
</div>
</div>
<h2 id="_introduction">Introduction</h2>
<div class="sectionbody">
<div class="paragraph"><p>The Context Framework, part of the Data Domain, provides a uniform,
high level API to numerous context properties of the device.  While
many of these context properties are available without the context
framework, each of them has its own specific way of accessing it.  The
context framework collects them all behind a uniform API, and
applications thus have easy access to all of the context properties.</p></div>
<div class="paragraph"><p>The following lists some typical context properties:</p></div>
<div class="ulist"><ul>
<li>
<p>
Connectivity status of the device; whether it is connected to the
  Internet and by what means.
</p>
</li>
<li>
<p>
Location; the name of the current city.
</p>
</li>
<li>
<p>
Builtin sensors; orientation in space.
</p>
</li>
<li>
<p>
Current use; idle, plays media, web browsing.
</p>
</li>
<li>
<p>
Combined properties; current weather based on location and online
  weather database.
</p>
</li>
</ul></div>
<div class="paragraph"><p>More concretely, the information in the status bar of a device is
provided exclusively by the Context Framework.</p></div>
<div class="paragraph"><p>Applications access context properties by using the <tt>ContextProperty</tt>
class that is implemented in api:libcontextsubscriber.</p></div>
<div class="paragraph"><p>The context framework is modular: context properties from multiple
independent components are directly combined in the
<tt>libcontextsubscriber</tt> API and applications can access them without
needing to know who is ultimately providing them.</p></div>
<div class="paragraph"><p>A component that wants to directly provide context properties needs to
implement the relevant interfaces defined by the context framework.
Currently, the only supported way to do that is to use the
api:libcontextprovider library.</p></div>
<div class="paragraph"><p>In addition to information from multiple sources, the context
framework is a provider of context properties itself: there is a
<em>context daemon</em> that collects information from low-level and legacy
interfaces.  This context daemon is a good default location for
implementing context properties and for absorbing properties from
existing subsystems that have aqcuired them for historical reasons and
would rather get rid of them.</p></div>
<div class="paragraph"><p>The concrete list of properties is ultimately defined by their
providers, but the context framework is the central authority: the
&#8216;official&#8217; list of context properties of the Maemo platform is defined
and documented by the context framework.</p></div>
<div class="paragraph"><p>To summarize, the context framework contributes value to the Maemo
platform in the following ways:</p></div>
<div class="ulist"><ul>
<li>
<p>
It implements and documents a high-level, uniform API to a set of
  context properties that are provided by multiple components.
</p>
</li>
<li>
<p>
It defines and documents the concrete list of properties of the
  Maemo platform.  This includes harmonizing the context ontology with
  other industry efforts.
</p>
</li>
<li>
<p>
It implements context properties that do not naturally belong to
  other subsystems and coordinates the implementation of context
  properties that do belong in specific subsystems.
</p>
</li>
<li>
<p>
It provides a debugging and exploration tool for inspecting and
  controlling context properties.
</p>
</li>
</ul></div>
<div class="paragraph"><p>Thus, the Context Framework does not drive the behavior of the system,
it only provides the information that is needed for other components
to decide for themselves.  To makes this reasonably easy, the context
properties are at a high level of abstraction and express the coarse
grained states of the device.  For example, the properties tell you
whether it is completely idle, in passive use playing some media, or
in active use.  They don&#8217;t give a real-time view of CPU load.</p></div>
</div>
<h2 id="_architecture">Architecture</h2>
<div class="sectionbody">
<h3 id="_concepts">Concepts</h3><div style="clear:left"></div>
<div class="paragraph"><p>Context properties are collected from all providers that have
registered themselves with the
<a href="context-providers.html"><tt>context-providers</tt></a> interface.  For each
provider, this registration information includes the list of its
properties with type information and a short description for each, and
the D-Bus bus name where the provider can be reached.  Providers can
be both on the session and on the system bus, and the registration
information indicates which bus it is.</p></div>
<div class="paragraph"><p>This registration information is read by the <tt>libcontextsubscriber</tt>
library and used by its <tt>ContextProperty</tt> class to connect a requested
property name to the right bus name.</p></div>
<div class="paragraph"><p>The registration information is compiled into a <em>cache</em> that is
optimized for use by <tt>libcontextsubscriber</tt>.  When the set of
registered properties changes, the cache is recompiled by a command
line utility provided by the context framework.  This will then
trigger all libcontextsubscriber clients to reload the registry
information, and existing <tt>ContextProperty</tt> instances to be updated.</p></div>
<div class="paragraph"><p>(Note that the cache only caches property declarations, it does not
ever contain the values of context properties.)</p></div>
<div class="paragraph"><p>When providers are installed from packages, recompilation of the cache
happens automatically.  <em>Triggers</em> in the Context Framework packages
are used to run the command line utility at the right times.</p></div>
<div class="paragraph"><p>The <tt>libcontextsubscriber</tt> library gracefully handles start, stop and
restart of providers. During system startup some applications may
start to use the Context Framework before all providers are
available. Properties become dynamically available as providers become
available, and removed when providers are no longer available.</p></div>
<div class="paragraph"><p>Communication between a <tt>ContextProperty</tt> and the provider happens
using a private D-Bus interface.  This interface allows for bulk
retrieval of property values, bulk subscriptions, and bulk change
notification.</p></div>
<div class="paragraph"><p>The values of properties are represented to clients as a <tt>QVariant</tt>
value.  Properties can have a special <em>null</em> value when they are not
available, either because they are not provided by any provider, or
because the provider is not able to deliver a value.  In other words,
the types of all context properties are "maybe types": subscribers
might get a value or not.  In general, the <em>null</em> value means that the
real value of the property is unknown.</p></div>
<div class="paragraph"><p>The <em>null</em> value is different from the empty string or the empty list.
For example, the "Location.City" property, which denotes the name of
the current city as a string, will be <em>null</em> when the name of the city
is unknown (either because the current location of the device is
unknown or because the database that maps from locations to city names
is not reachable), but it will be the empty string when the current
location is known to be outside of any city.</p></div>
<div class="paragraph"><p>The absence of a value can have many reasons: no provider is available
for this property, the provider has not yet delivered a value, or the
provider is deliberately not delivering a value, which it can in turn
have many reasons.  For example, necessary hardware might not be
present or its use might be disallowed by the current power management
policy, or a needed online database might not reachable.</p></div>
<div class="paragraph"><p>The Context Framework makes no attempt to distinguish these different
reasons.  Subscribers should make good use of a value when they get
it, but they must not fail catastrophically when no value is
available, or when it takes longer than expected for it to become
available.</p></div>
<div class="paragraph"><p>It is expected that eventually the statusbar plugins, such as the
battery charge monitor and the connectivity indicators, exclusively
use the context properties to retrieve the information they display.</p></div>
<div class="paragraph"><p>Context providers need to implement the private D-Bus interface.  This
is done with the api:libcontextprovider library.  This library is used
by the context daemon itself, which can serve as an extended example.</p></div>
<div class="paragraph"><p>The Connectivity Framework and the Sensor Framework are expected to be
context providers as described above.  Additional context properties,
such as those related to the Location Framework, are implemented by
the <em>context daemon</em> contained in the Context Framework.</p></div>
<div class="paragraph"><p>The <tt>contextd</tt> Context Daemon will implement all context properties
that don&#8217;t have a native provider.  It will at least implement
properties for the information contained in HAL and for location
related information.  It is expected that <tt>contextd</tt> runs the
necessary reverse geocoding operations at a reasonable frequency.  It
will also perform Content Framework queries to retrieve the values of
certain properties.</p></div>
<div class="paragraph"><p>If necessary for security reasons, the <tt>contextd</tt> might need to be
split into multiple instances.</p></div>
<h3 id="_system_context">System context</h3><div style="clear:left"></div>
<div class="paragraph"><p>The context framework decouples context subscribers from context
providers.</p></div>
<div class="svg">
<object type="image/png" data="fig3.png"/>
</div>
<h3 id="_structural_view">Structural view</h3><div style="clear:left"></div>
<div class="paragraph"><p>The following figure summarizes the components of the Context
Framework.</p></div>
<div class="svg">
<object type="image/png" data="fig4.png"/>
</div>
<div class="paragraph"><p>There are two fundamental options for exporting information via the
context framework:</p></div>
<div class="ulist"><ul>
<li>
<p>
The context daemon can use existing platform interfaces, such as
  HAL, to collect this information, process it, and export it as a
  context property.
 <br />
  This applies to: HAL, Location subsystem, Kernel.
</p>
</li>
<li>
<p>
The principal producer of the information, such as the <tt>icd2</tt> daemon
  in the Connectivity subsystem, can use the libcontextprovider API
  and export the information directly to applications without using
  the context daemon as a middle man.
 <br />
  This applies to: Sensor Framework, possibly Connectivity subsystem
  (needs agreeement), possibly Telephony subsystem (needs agreement)
</p>
</li>
</ul></div>
<h3 id="_provided_interfaces">Provided Interfaces</h3><div style="clear:left"></div>
<div class="paragraph"><div class="title"><tt>libcontextsubscriber</tt></div><p>A C++ API for listening to context properties.</p></div>
<div class="paragraph"><p><a href="libcontextsubscriber">Documentation</a></p></div>
<div class="paragraph"><div class="title"><tt>libcontextprovider</tt></div><p>A C++ and C API for providing values of context properties.</p></div>
<div class="paragraph"><p><a href="libcontextprovider">Documentation</a></p></div>
<div class="paragraph"><div class="title"><tt>context-properties</tt></div><p>The canonical list of context properties in the Maemo platform.  When
a context property from the list is available, it must conform to its
description there.</p></div>
<div class="paragraph"><p><a href="context-properties.html">Documentation</a></p></div>
<div class="paragraph"><div class="title"><tt>context-providers</tt></div><p>The interface to register providers of context properties.  A provider
must use the api:libcontextprovider API.</p></div>
<div class="paragraph"><p><a href="context-providers.html">Documentation</a></p></div>
<h3 id="_development_support">Development support</h3><div style="clear:left"></div>
<div class="paragraph"><p>No special features are needed in the Context Framework components to
make them work in a Scratchbox environment.  Availability of
individual properties depends on the ability of their providers to run
in Scratchbox.  The <tt>contextd</tt> Context Daemon runs but might not be
able to provide all properties.</p></div>
<div class="paragraph"><p>The Context Framework provides a graphical tool called the Context
Commander to watch all available context properties.  This can be used
to test context providers during development.</p></div>
<div class="paragraph"><p>In addition, the Context Commander can be used to force context
properties of selected applications to arbitrary values.  This can be
used to test the reaction of applications to context changes.</p></div>
<div class="paragraph"><p>The Context Commander runs on the device and either show its UI on the
device itself or exports it to an external X11 server.  This way, the
testing can be done without disturbing the display of the device
itself.</p></div>
<div class="paragraph"><p>When started, the Context Commander takes control of all subscribers
with their cooperation: when the
"org.freedesktop.ContextKit.Commander" name appears on the session
D-Bus, all ContextProperty instances redirect their subcription
requests to it.</p></div>
<div class="paragraph"><p>There are vague ideas about integrating the Context Commander into
Eclipse.</p></div>
<h3 id="_licenses">Licenses</h3><div style="clear:left"></div>
<div class="paragraph"><p>The components of the Context Framework will be developed publically,
under the umbrella of the freedesktop.org organization.  All source
code is licensed with LGPL 2.1, including the daemon and context
commander.</p></div>
<div class="paragraph"><p>Non-free source code can safely interact with the Context Framework
components.</p></div>
<h3 id="_user_data_settings_and_configurability">User Data, Settings, and Configurability</h3><div style="clear:left"></div>
<div class="paragraph"><p>The Context Framework does not store user data and is not
configurable.</p></div>
<h3 id="_configurability">Configurability</h3><div style="clear:left"></div>
<div class="paragraph"><p>See above.</p></div>
<h3 id="_packages">Packages</h3><div style="clear:left"></div>
<div class="dlist"><div class="title"><tt>contextkit</tt></div><dl>
<dt class="hdlist1">
Languages
</dt>
<dd>
<p>
C, C++
</p>
</dd>
<dt class="hdlist1">
License
</dt>
<dd>
<p>
LGPL 2.1
</p>
</dd>
<dt class="hdlist1">
Provided interfaces
</dt>
<dd>
<p>
libcontextsubscriber, libcontextprovider, context-providers, context-properties,
</p>
</dd>
<dt class="hdlist1">
Used interfaces
</dt>
<dd>
<p>
libdbus, libgee, libglib, libcdb, libqt4-dbus, libqt4-xml, libqtcore4
</p>
</dd>
<dt class="hdlist1">
Binary packages
</dt>
<dd>
<p>
 libcontextsubscriber0, libcontextsubscriber0-dbg, libcontextsubscriber-dev, libcontextsubscriber-doc,
 libcontextprovider0, libcontextprovider0-dbg, libcontextprovider-dev, libcontextprovider-doc,
 contextkit, contextkit-doc, context-dbg
</p>
</dd>
<dt class="hdlist1">
Sources
</dt>
<dd>
<p>
<a href="https://dvcs.projects.maemo.org/git/?p=ContextKit">https://dvcs.projects.maemo.org/git/?p=ContextKit</a>
</p>
</dd>
</dl></div>
<div class="dlist"><div class="title"><tt>context-commander</tt></div><dl>
<dt class="hdlist1">
Languages
</dt>
<dd>
<p>
C++
</p>
</dd>
<dt class="hdlist1">
License
</dt>
<dd>
<p>
LGPL 2.1
</p>
</dd>
<dt class="hdlist1">
Provided interfaces
</dt>
<dd>
<p>
none
</p>
</dd>
<dt class="hdlist1">
Used interfaces
</dt>
<dd>
<p>
libcontextsubscriber, libqt4-dbus, libqt4-gui, libqt4-core
</p>
</dd>
<dt class="hdlist1">
Binary packages
</dt>
<dd>
<p>
context-commander
</p>
</dd>
<dt class="hdlist1">
Sources
</dt>
<dd>
<p>
<a href="https://dvcs.projects.maemo.org/git/?p=ContextCommander">https://dvcs.projects.maemo.org/git/?p=ContextCommander</a>
</p>
</dd>
</dl></div>
<div class="dlist"><div class="title"><tt>context-provider-example</tt></div><dl>
<dt class="hdlist1">
Languages
</dt>
<dd>
<p>
C
</p>
</dd>
<dt class="hdlist1">
License
</dt>
<dd>
<p>
LGPL 2.1
</p>
</dd>
<dt class="hdlist1">
Provided interfaces
</dt>
<dd>
<p>
Context.Example.* properties.
</p>
</dd>
<dt class="hdlist1">
Used interfaces
</dt>
<dd>
<p>
libcontextprovider, sysfs files for accelerometer and ambient light sensor
</p>
</dd>
<dt class="hdlist1">
Binary packages
</dt>
<dd>
<p>
context-provider-example
</p>
</dd>
<dt class="hdlist1">
Sources
</dt>
<dd>
<p>
<a href="https://dvcs.projects.maemo.org/git/?p=ContextProviderExample">https://dvcs.projects.maemo.org/git/?p=ContextProviderExample</a>
</p>
</dd>
</dl></div>
<div class="dlist"><div class="title"><tt>context-subscriber-example</tt></div><dl>
<dt class="hdlist1">
Languages
</dt>
<dd>
<p>
C++
</p>
</dd>
<dt class="hdlist1">
License
</dt>
<dd>
<p>
LGPL 2.1
</p>
</dd>
<dt class="hdlist1">
Provided interfaces
</dt>
<dd>
<p>
none.
</p>
</dd>
<dt class="hdlist1">
Used interfaces
</dt>
<dd>
<p>
Context.Example.* properties, libcontextsubscriber, libqt4-gui, libqt4-core
</p>
</dd>
<dt class="hdlist1">
Binary packages
</dt>
<dd>
<p>
context-subscriber-example
</p>
</dd>
<dt class="hdlist1">
Sources
</dt>
<dd>
<p>
<a href="https://dvcs.projects.maemo.org/git/?p=ContextSubscriberExample">https://dvcs.projects.maemo.org/git/?p=ContextSubscriberExample</a>
</p>
</dd>
</dl></div>
</div>
<h2 id="_performance">Performance</h2>
<div class="sectionbody">
<h3 id="_general">General</h3><div style="clear:left"></div>
<div class="paragraph"><p>The Context Framework makes no real-time guarantees and does not rely
on any.</p></div>
<div class="paragraph"><p>It is careful not to cause significant additional communication that
wouldn&#8217;t be needed anyway to communicate contextual information to the
interested parties.</p></div>
<div class="paragraph"><p>We expect 5 to 10 providers, about 20 subscribers, each subscribed to
an average of 5 properties.  Property values can become arbitrarily
big, but are expected to be mostly small, in the order of 10 bytes.
The occasional big property value is expected to change
correspondingly infrequently.</p></div>
<h3 id="_memory">Memory</h3><div style="clear:left"></div>
<div class="tableblock">
<table rules="all"
width="100%"
frame="border"
cellspacing="0" cellpadding="4">
<col width="33%" />
<col width="33%" />
<col width="33%" />
<tbody>
<tr>
<td align="left" valign="top"><p class="table">OneNAND</p></td>
<td align="left" valign="top"><p class="table">All files are stored on the OneNAND, in their FHS mandated places</p></td>
<td align="left" valign="top"><p class="table">200 KiB</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">eMMC</p></td>
<td align="left" valign="top"><p class="table">Not used</p></td>
<td align="left" valign="top"><p class="table">0</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">RAM/Idle</p></td>
<td align="left" valign="top"><p class="table">A couple of bytes per subscription plus a couple more per provided property</p></td>
<td align="left" valign="top"><p class="table">200 KiB</p></td>
</tr>
<tr>
<td align="left" valign="top"><p class="table">RAM/Peak</p></td>
<td align="left" valign="top"><p class="table">The biggest property values might reach a KiB</p></td>
<td align="left" valign="top"><p class="table">500 KiB</p></td>
</tr>
</tbody>
</table>
</div>
<h3 id="_runtime">Runtime</h3><div style="clear:left"></div>
<div class="paragraph"><p>The Context Framework allows subscribers and providers to directly
connect to each other (incurring only the usual D-Bus daemon
overhead).  Context properties are expected to change only
infrequently and providers are urged to throttle the rate of change.</p></div>
<div class="paragraph"><p>The contextd daemon is started on the first subscription to one of its
properties.  This is expected to happen on every boot since it
provides properties that are used by other daemons, such as the
context engine.</p></div>
<h3 id="_power_consumption">Power consumption</h3><div style="clear:left"></div>
<div class="paragraph"><p>Providers of context properties know at any time whether someone in
the system is subscribed to them.  This allows them to avoid expensive
operations for producing values that are not needed.</p></div>
<div class="paragraph"><p>The documentation for subscribers urges them to take the cost of
producing property values into consideration.  The subscriber API
offers an easy way to temporarily suspend a subscription.</p></div>
<div class="paragraph"><p>Sometimes, increased granularity of control over a property is needed:
instead of just switching it on and off, the subscriber might want to
request different levels of quality.  For example, some subscribers
might need a higher update frequency than others and are willing to
pay the associated price in power consumption.</p></div>
<div class="paragraph"><p>The recommended way to implement this increased control is to offer
multiple properties that deliver the same value but with different
qualities-of-service.  For example, there could be both
"Location.HighResCoordinates" and "Location.LowResCoordinates"
properties that both deliver the current geographical coordinates.
Subscribing to "Location.HighResCoordinates", however, would cause the
location to be updated more frequently and maybe even activate a GPS
device, if available.</p></div>
</div>
<h2 id="_security_impact">Security Impact</h2>
<div class="sectionbody">
<div class="paragraph"><p>Different context properties might need to have different access
restrictions.  A context provider can implement these access
restriction in whatever way works, but should preferrably use the
existing features of the Security Framework.</p></div>
<div class="paragraph"><p>The Security Framework can control access per D-Bus bus connection.
Thus, a given context provider should only implement properties with
the same access rights and leave it to the Security Framework to allow
or disallow connections to the provider as a whole.</p></div>
<div class="paragraph"><p>The Context Daemon needs to follow the same rules, of course.</p></div>
<div class="paragraph"><p>The libcontextsubscriber library listens for a special D-Bus bus name
to appear and then allows the service behind that name to override all
values of context properties.  The library protects this special name
with a security token so that only specially certified software can
own this name.  The context commander might or might not be certified
in this way; instead of certifying it, it might be preferrable to
require developers to explicitly disable the name protection (via a
developer certificate or a general device unlocking ceremony) before
they can use the context commander.</p></div>
</div>
<h2 id="_open_items">Open Items</h2>
<div class="sectionbody">
<div class="ulist"><ul>
<li>
<p>
The D-Bus interface needs to be reviewed and maybe redesigned.  It
  might make sense to use one object path per property instead of one
  object path per subscriber like we do now.
</p>
</li>
<li>
<p>
Integration with Content Framework needs to be addressed.  Snapshots
  of the current context need to be imported into the content database
  (as document tags, say) and content queries might be run
  periodically to provide contextual information (such as the ten most
  recently accessed documents).
</p>
</li>
<li>
<p>
The current plan for localization of context properties requires
  context providers to do it.  They thusly need access to the current
  device language and rumour has it that everything about l10n is
  different in Harmattan.
</p>
</li>
</ul></div>
</div>
<h2 id="_appendices">Appendices</h2>
<div class="sectionbody">
<h3 id="_the_context_framework_for_context_providers">The Context Framework for Context Providers</h3><div style="clear:left"></div>
<div class="paragraph"><p>The advantages of the Context Framework for application writers should
be clear: they can access a rich set of useful contextual information
with a simple API.</p></div>
<div class="paragraph"><p>The ultimate providers of this information, however, might feel that
the context framework itself does not add significant value: after
all, they already implement APIs to access all that information
anyway.  Hooking into the Context Framework means a duplication of
effort and the requirement to express everything as a value (instead
of a general query/response API) might be unwelcome.</p></div>
<div class="paragraph"><p>However, the unified API and central maintenance of the list of core
properties carries a lot of value:</p></div>
<div class="ulist"><ul>
<li>
<p>
It makes using more contextual information trivial once you have
  used your first property.
</p>
</li>
<li>
<p>
It makes it possible to expose present and future context
  information in all kinds of places with a single effort.  Once the
  context framework has been integrated into the Web runtime, into
  Python, or into any language that people care about, no additional
  effort is needed by anyone to track future developments of the
  context properties.
</p>
</li>
<li>
<p>
It decouples context providers from consumers.  The context
  framework makes it possible to move the implementation of a property
  from one component to another without having to restart the
  consumers.
</p>
</li>
<li>
<p>
It makes it worthwhile to develop sophisticated tools such as the
  context commander and support for easy automated testing of context
  subscribers and providers.
</p>
</li>
<li>
<p>
It might allow some context providers to exit the "API business"
  altogether.
</p>
<div class="paragraph"><p>If a piece of information is available in a corner of the system but
needed somewhere else, it is only human to see this as a nuisance
and cobble together a few D-Bus methods to access that information.</p></div>
<div class="paragraph"><p>The context framework provides a good alternative in those cases.</p></div>
</li>
</ul></div>
<div class="paragraph"><p>It is thus our opinion that the context framework provides enough
value to justify pushing it into other peoples subsystems, even if
that means duplicated efforts.</p></div>
<div class="paragraph"><p>Moreover, the effort needed to integrate with the context framework is
low.</p></div>
<h3 id="_relation_to_policy_engine">Relation to Policy Engine</h3><div style="clear:left"></div>
<div class="paragraph"><p>The policy engine has the role in the Maemo platform to decide system
global behavior and controls the various distributed enforcement
points accordingly.  This job will likely be done by OHMng.</p></div>
<div class="paragraph"><p>The policy engine can be both a subscriber to and provider of context
properties.  The policy engine will base its decisions (partly) on the
current values of context properties and will publish (part of) its
decisions as context properties.</p></div>
<div class="paragraph"><p>Most facts that need to be gathered as input for the policy engine can
be communicted to it via the context framework.  If necessary,
non-public context properties can be defined that (while visible to
everyone who knows where to look) are not maintained as part of the
list of core properties.</p></div>
<div class="paragraph"><p>Decisions of the policy engine can be communicated to cooperating
applications and potentially even to enforcement points.  The set of
values representable as context properties is quite rich so that
hopefully all facts and decisions can be represented with them.</p></div>
</div>
<div id="footer">
<div id="footer-text">
Last updated 2009-10-23 15:50:03 EEST
</div>
</div>
</body>
</html>