Merge lp:~jplacerda/libzeitgeist/776651 into lp:libzeitgeist
- 776651
- Merge into trunk
Proposed by
J.P. Lacerda
Status: | Rejected | ||||||||
---|---|---|---|---|---|---|---|---|---|
Rejected by: | Mikkel Kamstrup Erlandsen | ||||||||
Proposed branch: | lp:~jplacerda/libzeitgeist/776651 | ||||||||
Merge into: | lp:libzeitgeist | ||||||||
Diff against target: |
454 lines (+130/-11) 5 files modified
src/zeitgeist-event.c (+64/-5) src/zeitgeist-event.h (+6/-0) src/zeitgeist-subject.c (+37/-3) src/zeitgeist-subject.h (+6/-1) tests/test-event.c (+17/-2) |
||||||||
To merge this branch: | bzr merge lp:~jplacerda/libzeitgeist/776651 | ||||||||
Related bugs: |
|
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Mikkel Kamstrup Erlandsen | Pending | ||
Review via email:
|
Commit message
Description of the change
To post a comment you must log in.
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Siegfried Gevatter (rainct) wrote : | # |
It's missing support for old variants (without origin/
Nice work!
I'm uploading an updated branch with that fix plus removing the changes to the constructors for now, since those break the API (we can introduce them at some later point).
Revision history for this message
![](/+icing/build/overlay/assets/skins/sam/images/close.gif)
Mikkel Kamstrup Erlandsen (kamstrup) wrote : | # |
Siegfried's work is now in lp:~rainct/libzeitgeist/event-origin-subject-current-uri
Unmerged revisions
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'src/zeitgeist-event.c' | |||
2 | --- src/zeitgeist-event.c 2011-03-25 12:14:46 +0000 | |||
3 | +++ src/zeitgeist-event.c 2011-05-11 16:08:25 +0000 | |||
4 | @@ -82,6 +82,7 @@ | |||
5 | 82 | ZEITGEIST_EVENT_INTERPRETATION, | 82 | ZEITGEIST_EVENT_INTERPRETATION, |
6 | 83 | ZEITGEIST_EVENT_MANIFESTATION, | 83 | ZEITGEIST_EVENT_MANIFESTATION, |
7 | 84 | ZEITGEIST_EVENT_ACTOR, | 84 | ZEITGEIST_EVENT_ACTOR, |
8 | 85 | ZEITGEIST_EVENT_ORIGIN, | ||
9 | 85 | } ZeitgeistEventDataOffset; | 86 | } ZeitgeistEventDataOffset; |
10 | 86 | 87 | ||
11 | 87 | typedef struct | 88 | typedef struct |
12 | @@ -91,6 +92,7 @@ | |||
13 | 91 | gchar *interpretation; | 92 | gchar *interpretation; |
14 | 92 | gchar *manifestation; | 93 | gchar *manifestation; |
15 | 93 | gchar *actor; | 94 | gchar *actor; |
16 | 95 | gchar *origin; | ||
17 | 94 | GPtrArray *subjects; | 96 | GPtrArray *subjects; |
18 | 95 | GByteArray *payload; | 97 | GByteArray *payload; |
19 | 96 | } ZeitgeistEventPrivate; | 98 | } ZeitgeistEventPrivate; |
20 | @@ -431,6 +433,51 @@ | |||
21 | 431 | } | 433 | } |
22 | 432 | 434 | ||
23 | 433 | /** | 435 | /** |
24 | 436 | * zeitgeist_event_get_origin: | ||
25 | 437 | * @event: The event to get the origin from | ||
26 | 438 | * | ||
27 | 439 | * Get the origin of an event. | ||
28 | 440 | * This differs from a subject's origin, as it described where the event comes | ||
29 | 441 | * from, not where it resides. | ||
30 | 442 | * | ||
31 | 443 | * Returns: The origin of @event. | ||
32 | 444 | */ | ||
33 | 445 | const gchar* | ||
34 | 446 | zeitgeist_event_get_origin (ZeitgeistEvent *event) | ||
35 | 447 | { | ||
36 | 448 | g_return_val_if_fail (ZEITGEIST_IS_EVENT (event), NULL); | ||
37 | 449 | |||
38 | 450 | ZeitgeistEventPrivate* priv = ZEITGEIST_EVENT_GET_PRIVATE (event); | ||
39 | 451 | |||
40 | 452 | return priv->origin; | ||
41 | 453 | } | ||
42 | 454 | |||
43 | 455 | /** | ||
44 | 456 | * zeitgeist_event_set_origin: | ||
45 | 457 | * @event: The event to set the origin of | ||
46 | 458 | * @origin: The origin to set | ||
47 | 459 | * | ||
48 | 460 | * Set the origin of an event. | ||
49 | 461 | */ | ||
50 | 462 | void | ||
51 | 463 | zeitgeist_event_set_origin (ZeitgeistEvent *event, | ||
52 | 464 | const gchar *origin) | ||
53 | 465 | { | ||
54 | 466 | g_return_if_fail (ZEITGEIST_IS_EVENT (event)); | ||
55 | 467 | |||
56 | 468 | ZeitgeistEventPrivate* priv = ZEITGEIST_EVENT_GET_PRIVATE (event); | ||
57 | 469 | |||
58 | 470 | gchar* copy = g_strdup (origin); | ||
59 | 471 | |||
60 | 472 | if (priv->origin) | ||
61 | 473 | { | ||
62 | 474 | g_free (priv->origin); | ||
63 | 475 | } | ||
64 | 476 | |||
65 | 477 | priv->origin = copy; | ||
66 | 478 | } | ||
67 | 479 | |||
68 | 480 | /** | ||
69 | 434 | * zeitgeist_event_get_payload: | 481 | * zeitgeist_event_get_payload: |
70 | 435 | * @event: The event to get the payload for | 482 | * @event: The event to get the payload for |
71 | 436 | * | 483 | * |
72 | @@ -439,7 +486,6 @@ | |||
73 | 439 | * Returns: The event payload or %NULL if unset. Do not free. If you want to | 486 | * Returns: The event payload or %NULL if unset. Do not free. If you want to |
74 | 440 | * keep the subject around you need to g_byte_array_ref() it. | 487 | * keep the subject around you need to g_byte_array_ref() it. |
75 | 441 | */ | 488 | */ |
76 | 442 | |||
77 | 443 | GByteArray* | 489 | GByteArray* |
78 | 444 | zeitgeist_event_get_payload (ZeitgeistEvent *event) | 490 | zeitgeist_event_get_payload (ZeitgeistEvent *event) |
79 | 445 | { | 491 | { |
80 | @@ -491,6 +537,7 @@ | |||
81 | 491 | priv->interpretation = NULL; | 537 | priv->interpretation = NULL; |
82 | 492 | priv->manifestation = NULL; | 538 | priv->manifestation = NULL; |
83 | 493 | priv->actor = NULL; | 539 | priv->actor = NULL; |
84 | 540 | priv->origin = NULL; | ||
85 | 494 | priv->subjects = g_ptr_array_new_with_free_func ( | 541 | priv->subjects = g_ptr_array_new_with_free_func ( |
86 | 495 | (GDestroyNotify)g_object_unref); | 542 | (GDestroyNotify)g_object_unref); |
87 | 496 | priv->payload = NULL; | 543 | priv->payload = NULL; |
88 | @@ -506,14 +553,15 @@ | |||
89 | 506 | 553 | ||
90 | 507 | if (priv->subjects) | 554 | if (priv->subjects) |
91 | 508 | { | 555 | { |
93 | 509 | /* Subjects are unreffed by the free-func of the GPtrArray */ | 556 | /* Subjects are unreffed by the free-func of the GPtrArray */ |
94 | 510 | g_ptr_array_unref (priv->subjects); | 557 | g_ptr_array_unref (priv->subjects); |
95 | 511 | priv->subjects = NULL; | 558 | priv->subjects = NULL; |
96 | 512 | } | 559 | } |
97 | 513 | 560 | ||
98 | 514 | zeitgeist_event_set_interpretation (event, NULL); | 561 | zeitgeist_event_set_interpretation (event, NULL); |
99 | 515 | zeitgeist_event_set_manifestation (event, NULL); | 562 | zeitgeist_event_set_manifestation (event, NULL); |
101 | 516 | zeitgeist_event_set_actor (event, NULL); | 563 | zeitgeist_event_set_actor (event, NULL); |
102 | 564 | zeitgeist_event_set_origin (event, NULL); | ||
103 | 517 | zeitgeist_event_set_payload (event, NULL); | 565 | zeitgeist_event_set_payload (event, NULL); |
104 | 518 | 566 | ||
105 | 519 | G_OBJECT_CLASS (zeitgeist_event_parent_class)->finalize (object); | 567 | G_OBJECT_CLASS (zeitgeist_event_parent_class)->finalize (object); |
106 | @@ -574,14 +622,15 @@ | |||
107 | 574 | zeitgeist_event_new_full (const gchar *interpretation, | 622 | zeitgeist_event_new_full (const gchar *interpretation, |
108 | 575 | const gchar *manifestation, | 623 | const gchar *manifestation, |
109 | 576 | const gchar *actor, | 624 | const gchar *actor, |
110 | 625 | const gchar *origin, | ||
111 | 577 | ...) | 626 | ...) |
112 | 578 | { | 627 | { |
113 | 579 | va_list args; | 628 | va_list args; |
114 | 580 | ZeitgeistEvent *self; | 629 | ZeitgeistEvent *self; |
115 | 581 | 630 | ||
117 | 582 | va_start (args, actor); | 631 | va_start (args, origin); |
118 | 583 | self = zeitgeist_event_new_full_valist (interpretation, manifestation, | 632 | self = zeitgeist_event_new_full_valist (interpretation, manifestation, |
120 | 584 | actor, args); | 633 | actor, origin, args); |
121 | 585 | va_end (args); | 634 | va_end (args); |
122 | 586 | 635 | ||
123 | 587 | return self; | 636 | return self; |
124 | @@ -605,6 +654,7 @@ | |||
125 | 605 | zeitgeist_event_new_full_valist (const gchar *interpretation, | 654 | zeitgeist_event_new_full_valist (const gchar *interpretation, |
126 | 606 | const gchar *manifestation, | 655 | const gchar *manifestation, |
127 | 607 | const gchar *actor, | 656 | const gchar *actor, |
128 | 657 | const gchar *origin, | ||
129 | 608 | va_list args) | 658 | va_list args) |
130 | 609 | { | 659 | { |
131 | 610 | ZeitgeistEvent *self; | 660 | ZeitgeistEvent *self; |
132 | @@ -614,6 +664,7 @@ | |||
133 | 614 | zeitgeist_event_set_interpretation (self, interpretation); | 664 | zeitgeist_event_set_interpretation (self, interpretation); |
134 | 615 | zeitgeist_event_set_manifestation (self, manifestation); | 665 | zeitgeist_event_set_manifestation (self, manifestation); |
135 | 616 | zeitgeist_event_set_actor (self, actor); | 666 | zeitgeist_event_set_actor (self, actor); |
136 | 667 | zeitgeist_event_set_origin (self, origin); | ||
137 | 617 | 668 | ||
138 | 618 | subject = va_arg (args, ZeitgeistSubject*); | 669 | subject = va_arg (args, ZeitgeistSubject*); |
139 | 619 | while (subject != NULL) | 670 | while (subject != NULL) |
140 | @@ -686,6 +737,9 @@ | |||
141 | 686 | g_variant_iter_loop (event_data, "s", &str); | 737 | g_variant_iter_loop (event_data, "s", &str); |
142 | 687 | zeitgeist_event_set_actor (result, str[0] == '\0' ? NULL : str); | 738 | zeitgeist_event_set_actor (result, str[0] == '\0' ? NULL : str); |
143 | 688 | 739 | ||
144 | 740 | g_variant_iter_loop (event_data, "s", &str); | ||
145 | 741 | zeitgeist_event_set_origin (result, str[0] == '\0' ? NULL : str); | ||
146 | 742 | |||
147 | 689 | /* Build the list of subjects */ | 743 | /* Build the list of subjects */ |
148 | 690 | while (g_variant_iter_loop (subjects, "as", &subject_data)) | 744 | while (g_variant_iter_loop (subjects, "as", &subject_data)) |
149 | 691 | { | 745 | { |
150 | @@ -720,6 +774,9 @@ | |||
151 | 720 | g_variant_iter_loop (subject_data, "s", &str); | 774 | g_variant_iter_loop (subject_data, "s", &str); |
152 | 721 | zeitgeist_subject_set_storage (subject, str[0] == '\0' ? NULL : str); | 775 | zeitgeist_subject_set_storage (subject, str[0] == '\0' ? NULL : str); |
153 | 722 | 776 | ||
154 | 777 | g_variant_iter_loop (subject_data, "s", &str); | ||
155 | 778 | zeitgeist_subject_set_current_uri (subject, str[0] == '\0' ? NULL : str); | ||
156 | 779 | |||
157 | 723 | zeitgeist_event_add_subject (result, subject); | 780 | zeitgeist_event_add_subject (result, subject); |
158 | 724 | } | 781 | } |
159 | 725 | 782 | ||
160 | @@ -787,6 +844,7 @@ | |||
161 | 787 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_interpretation(event), bif ? bif : "")); | 844 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_interpretation(event), bif ? bif : "")); |
162 | 788 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_manifestation(event), bif ? bif : "")); | 845 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_manifestation(event), bif ? bif : "")); |
163 | 789 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_actor (event), bif ? bif : "")); | 846 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_actor (event), bif ? bif : "")); |
164 | 847 | g_variant_builder_add (&b, "s", (bif = zeitgeist_event_get_origin (event), bif ? bif : "")); | ||
165 | 790 | g_variant_builder_close (&b); | 848 | g_variant_builder_close (&b); |
166 | 791 | 849 | ||
167 | 792 | /* Build subjects */ | 850 | /* Build subjects */ |
168 | @@ -803,6 +861,7 @@ | |||
169 | 803 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_mimetype(su), bif ? bif : "")); | 861 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_mimetype(su), bif ? bif : "")); |
170 | 804 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_text(su), bif ? bif : "")); | 862 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_text(su), bif ? bif : "")); |
171 | 805 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_storage(su), bif ? bif : "")); | 863 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_storage(su), bif ? bif : "")); |
172 | 864 | g_variant_builder_add (&b, "s", (bif = zeitgeist_subject_get_current_uri(su), bif ? bif : "")); | ||
173 | 806 | g_variant_builder_close (&b); | 865 | g_variant_builder_close (&b); |
174 | 807 | } | 866 | } |
175 | 808 | g_variant_builder_close (&b); | 867 | g_variant_builder_close (&b); |
176 | 809 | 868 | ||
177 | === modified file 'src/zeitgeist-event.h' | |||
178 | --- src/zeitgeist-event.h 2011-03-07 14:19:39 +0000 | |||
179 | +++ src/zeitgeist-event.h 2011-05-11 16:08:25 +0000 | |||
180 | @@ -70,11 +70,13 @@ | |||
181 | 70 | ZeitgeistEvent* zeitgeist_event_new_full (const gchar *interpretation, | 70 | ZeitgeistEvent* zeitgeist_event_new_full (const gchar *interpretation, |
182 | 71 | const gchar *manifestation, | 71 | const gchar *manifestation, |
183 | 72 | const gchar *actor, | 72 | const gchar *actor, |
184 | 73 | const gchar *origin, | ||
185 | 73 | ...) G_GNUC_NULL_TERMINATED; | 74 | ...) G_GNUC_NULL_TERMINATED; |
186 | 74 | 75 | ||
187 | 75 | ZeitgeistEvent* zeitgeist_event_new_full_valist (const gchar *interpretation, | 76 | ZeitgeistEvent* zeitgeist_event_new_full_valist (const gchar *interpretation, |
188 | 76 | const gchar *manifestation, | 77 | const gchar *manifestation, |
189 | 77 | const gchar *actor, | 78 | const gchar *actor, |
190 | 79 | const gchar *origin, | ||
191 | 78 | va_list args); | 80 | va_list args); |
192 | 79 | 81 | ||
193 | 80 | ZeitgeistEvent* zeitgeist_event_new_from_variant (GVariant *event); | 82 | ZeitgeistEvent* zeitgeist_event_new_from_variant (GVariant *event); |
194 | @@ -104,6 +106,10 @@ | |||
195 | 104 | void zeitgeist_event_set_actor (ZeitgeistEvent *event, | 106 | void zeitgeist_event_set_actor (ZeitgeistEvent *event, |
196 | 105 | const gchar *actor); | 107 | const gchar *actor); |
197 | 106 | 108 | ||
198 | 109 | const gchar* zeitgeist_event_get_origin (ZeitgeistEvent *event); | ||
199 | 110 | void zeitgeist_event_set_origin (ZeitgeistEvent *event, | ||
200 | 111 | const gchar *origin); | ||
201 | 112 | |||
202 | 107 | void zeitgeist_event_set_actor_from_app_info (ZeitgeistEvent *event, | 113 | void zeitgeist_event_set_actor_from_app_info (ZeitgeistEvent *event, |
203 | 108 | GAppInfo *appinfo); | 114 | GAppInfo *appinfo); |
204 | 109 | 115 | ||
205 | 110 | 116 | ||
206 | === modified file 'src/zeitgeist-subject.c' | |||
207 | --- src/zeitgeist-subject.c 2011-03-07 14:19:39 +0000 | |||
208 | +++ src/zeitgeist-subject.c 2011-05-11 16:08:25 +0000 | |||
209 | @@ -43,6 +43,8 @@ | |||
210 | 43 | ZEITGEIST_SUBJECT_MIMETYPE, | 43 | ZEITGEIST_SUBJECT_MIMETYPE, |
211 | 44 | ZEITGEIST_SUBJECT_ORIGIN, | 44 | ZEITGEIST_SUBJECT_ORIGIN, |
212 | 45 | ZEITGEIST_SUBJECT_TEXT, | 45 | ZEITGEIST_SUBJECT_TEXT, |
213 | 46 | ZEITGEIST_SUBJECT_STORAGE, | ||
214 | 47 | ZEITGEIST_SUBJECT_CURRENT_URI, | ||
215 | 46 | } ZeitgeistSubjectDataOffset; | 48 | } ZeitgeistSubjectDataOffset; |
216 | 47 | 49 | ||
217 | 48 | typedef struct | 50 | typedef struct |
218 | @@ -54,6 +56,7 @@ | |||
219 | 54 | gchar *origin; | 56 | gchar *origin; |
220 | 55 | gchar *text; | 57 | gchar *text; |
221 | 56 | gchar *storage; | 58 | gchar *storage; |
222 | 59 | gchar *current_uri; | ||
223 | 57 | } ZeitgeistSubjectPrivate; | 60 | } ZeitgeistSubjectPrivate; |
224 | 58 | 61 | ||
225 | 59 | const gchar* | 62 | const gchar* |
226 | @@ -245,6 +248,33 @@ | |||
227 | 245 | priv->storage = copy; | 248 | priv->storage = copy; |
228 | 246 | } | 249 | } |
229 | 247 | 250 | ||
230 | 251 | const gchar* | ||
231 | 252 | zeitgeist_subject_get_current_uri (ZeitgeistSubject *subject) | ||
232 | 253 | { | ||
233 | 254 | g_return_val_if_fail (ZEITGEIST_IS_SUBJECT (subject), NULL); | ||
234 | 255 | |||
235 | 256 | ZeitgeistSubjectPrivate *priv = ZEITGEIST_SUBJECT_GET_PRIVATE (subject); | ||
236 | 257 | return priv->current_uri; | ||
237 | 258 | } | ||
238 | 259 | |||
239 | 260 | void | ||
240 | 261 | zeitgeist_subject_set_current_uri (ZeitgeistSubject *subject, | ||
241 | 262 | const gchar *current_uri) | ||
242 | 263 | { | ||
243 | 264 | g_return_if_fail (ZEITGEIST_IS_SUBJECT (subject)); | ||
244 | 265 | |||
245 | 266 | ZeitgeistSubjectPrivate *priv = ZEITGEIST_SUBJECT_GET_PRIVATE (subject); | ||
246 | 267 | |||
247 | 268 | gchar* copy = g_strdup (current_uri); | ||
248 | 269 | |||
249 | 270 | if (priv->current_uri) | ||
250 | 271 | { | ||
251 | 272 | g_free (priv->current_uri); | ||
252 | 273 | } | ||
253 | 274 | |||
254 | 275 | priv->current_uri = copy; | ||
255 | 276 | } | ||
256 | 277 | |||
257 | 248 | static void | 278 | static void |
258 | 249 | zeitgeist_subject_init (ZeitgeistSubject *object) | 279 | zeitgeist_subject_init (ZeitgeistSubject *object) |
259 | 250 | { | 280 | { |
260 | @@ -258,6 +288,7 @@ | |||
261 | 258 | priv->origin = NULL; | 288 | priv->origin = NULL; |
262 | 259 | priv->text = NULL; | 289 | priv->text = NULL; |
263 | 260 | priv->storage = NULL; | 290 | priv->storage = NULL; |
264 | 291 | priv->current_uri = NULL; | ||
265 | 261 | } | 292 | } |
266 | 262 | 293 | ||
267 | 263 | static void | 294 | static void |
268 | @@ -275,6 +306,7 @@ | |||
269 | 275 | zeitgeist_subject_set_origin (subject, NULL); | 306 | zeitgeist_subject_set_origin (subject, NULL); |
270 | 276 | zeitgeist_subject_set_text (subject, NULL); | 307 | zeitgeist_subject_set_text (subject, NULL); |
271 | 277 | zeitgeist_subject_set_storage (subject, NULL); | 308 | zeitgeist_subject_set_storage (subject, NULL); |
272 | 309 | zeitgeist_subject_set_current_uri (subject, NULL); | ||
273 | 278 | 310 | ||
274 | 279 | G_OBJECT_CLASS (zeitgeist_subject_parent_class)->finalize (object); | 311 | G_OBJECT_CLASS (zeitgeist_subject_parent_class)->finalize (object); |
275 | 280 | } | 312 | } |
276 | @@ -319,7 +351,7 @@ | |||
277 | 319 | * @text: A small textual representation of the subject suitable for display | 351 | * @text: A small textual representation of the subject suitable for display |
278 | 320 | * @storage: String identifier for the storage medium the subject is on. | 352 | * @storage: String identifier for the storage medium the subject is on. |
279 | 321 | * Se zeitgeist_subject_set_storage() for details | 353 | * Se zeitgeist_subject_set_storage() for details |
281 | 322 | * | 354 | * @current_uri: The current URI or URL of the subject |
282 | 323 | * Create a new subject structure with predefined data | 355 | * Create a new subject structure with predefined data |
283 | 324 | * | 356 | * |
284 | 325 | * Returns: A newly create #ZeitgeistSubject instance. The returned subject will | 357 | * Returns: A newly create #ZeitgeistSubject instance. The returned subject will |
285 | @@ -335,7 +367,8 @@ | |||
286 | 335 | const gchar *mimetype, | 367 | const gchar *mimetype, |
287 | 336 | const gchar *origin, | 368 | const gchar *origin, |
288 | 337 | const gchar *text, | 369 | const gchar *text, |
290 | 338 | const gchar *storage) | 370 | const gchar *storage, |
291 | 371 | const gchar *current_uri) | ||
292 | 339 | { | 372 | { |
293 | 340 | ZeitgeistSubject *self; | 373 | ZeitgeistSubject *self; |
294 | 341 | 374 | ||
295 | @@ -347,6 +380,7 @@ | |||
296 | 347 | zeitgeist_subject_set_origin (self, origin); | 380 | zeitgeist_subject_set_origin (self, origin); |
297 | 348 | zeitgeist_subject_set_text (self, text); | 381 | zeitgeist_subject_set_text (self, text); |
298 | 349 | zeitgeist_subject_set_storage (self, storage); | 382 | zeitgeist_subject_set_storage (self, storage); |
300 | 350 | 383 | zeitgeist_subject_set_current_uri (self, current_uri); | |
301 | 384 | |||
302 | 351 | return self; | 385 | return self; |
303 | 352 | } | 386 | } |
304 | 353 | 387 | ||
305 | === modified file 'src/zeitgeist-subject.h' | |||
306 | --- src/zeitgeist-subject.h 2011-03-07 14:19:39 +0000 | |||
307 | +++ src/zeitgeist-subject.h 2011-05-11 16:08:25 +0000 | |||
308 | @@ -71,7 +71,8 @@ | |||
309 | 71 | const gchar *mimetype, | 71 | const gchar *mimetype, |
310 | 72 | const gchar *origin, | 72 | const gchar *origin, |
311 | 73 | const gchar *text, | 73 | const gchar *text, |
313 | 74 | const gchar *storage); | 74 | const gchar *storage, |
314 | 75 | const gchar *current_uri); | ||
315 | 75 | 76 | ||
316 | 76 | const gchar* zeitgeist_subject_get_uri (ZeitgeistSubject *subject); | 77 | const gchar* zeitgeist_subject_get_uri (ZeitgeistSubject *subject); |
317 | 77 | void zeitgeist_subject_set_uri (ZeitgeistSubject *subject, | 78 | void zeitgeist_subject_set_uri (ZeitgeistSubject *subject, |
318 | @@ -101,6 +102,10 @@ | |||
319 | 101 | void zeitgeist_subject_set_storage (ZeitgeistSubject *subject, | 102 | void zeitgeist_subject_set_storage (ZeitgeistSubject *subject, |
320 | 102 | const gchar *storage); | 103 | const gchar *storage); |
321 | 103 | 104 | ||
322 | 105 | const gchar* zeitgeist_subject_get_current_uri (ZeitgeistSubject *subject); | ||
323 | 106 | void zeitgeist_subject_set_current_uri (ZeitgeistSubject *subject, | ||
324 | 107 | const gchar *current_uri); | ||
325 | 108 | |||
326 | 104 | G_END_DECLS | 109 | G_END_DECLS |
327 | 105 | 110 | ||
328 | 106 | #endif /* _ZEITGEIST_SUBJECT_H_ */ | 111 | #endif /* _ZEITGEIST_SUBJECT_H_ */ |
329 | 107 | 112 | ||
330 | === modified file 'tests/test-event.c' | |||
331 | --- tests/test-event.c 2011-02-14 08:27:28 +0000 | |||
332 | +++ tests/test-event.c 2011-05-11 16:08:25 +0000 | |||
333 | @@ -62,6 +62,7 @@ | |||
334 | 62 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_interpretation (ev)); | 62 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_interpretation (ev)); |
335 | 63 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_manifestation (ev)); | 63 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_manifestation (ev)); |
336 | 64 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_actor (ev)); | 64 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_actor (ev)); |
337 | 65 | g_assert_cmpstr (NULL, ==, zeitgeist_event_get_origin (ev)); | ||
338 | 65 | g_assert_cmpint (0, ==, zeitgeist_event_num_subjects (ev)); | 66 | g_assert_cmpint (0, ==, zeitgeist_event_num_subjects (ev)); |
339 | 66 | g_assert (zeitgeist_event_get_payload (ev) == NULL); | 67 | g_assert (zeitgeist_event_get_payload (ev) == NULL); |
340 | 67 | 68 | ||
341 | @@ -79,13 +80,15 @@ | |||
342 | 79 | ZEITGEIST_ZG_ACCESS_EVENT, | 80 | ZEITGEIST_ZG_ACCESS_EVENT, |
343 | 80 | ZEITGEIST_ZG_USER_ACTIVITY, | 81 | ZEITGEIST_ZG_USER_ACTIVITY, |
344 | 81 | "application://firefox.desktop", | 82 | "application://firefox.desktop", |
345 | 83 | "origin", | ||
346 | 82 | zeitgeist_subject_new_full ("http://example.com", | 84 | zeitgeist_subject_new_full ("http://example.com", |
347 | 83 | ZEITGEIST_NFO_WEBSITE, | 85 | ZEITGEIST_NFO_WEBSITE, |
348 | 84 | ZEITGEIST_NFO_REMOTE_DATA_OBJECT, | 86 | ZEITGEIST_NFO_REMOTE_DATA_OBJECT, |
349 | 85 | "text/html", | 87 | "text/html", |
350 | 86 | "http://example.com", | 88 | "http://example.com", |
351 | 87 | "example.com", | 89 | "example.com", |
353 | 88 | "net"), | 90 | "net", |
354 | 91 | "http://current-example.com"), | ||
355 | 89 | zeitgeist_subject_new (), | 92 | zeitgeist_subject_new (), |
356 | 90 | NULL); | 93 | NULL); |
357 | 91 | 94 | ||
358 | @@ -94,6 +97,7 @@ | |||
359 | 94 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (ev)); | 97 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (ev)); |
360 | 95 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (ev)); | 98 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (ev)); |
361 | 96 | g_assert_cmpstr ("application://firefox.desktop", ==, zeitgeist_event_get_actor (ev)); | 99 | g_assert_cmpstr ("application://firefox.desktop", ==, zeitgeist_event_get_actor (ev)); |
362 | 100 | g_assert_cmpstr ("origin", ==, zeitgeist_event_get_origin (ev)); | ||
363 | 97 | g_assert_cmpint (2, ==, zeitgeist_event_num_subjects (ev)); | 101 | g_assert_cmpint (2, ==, zeitgeist_event_num_subjects (ev)); |
364 | 98 | g_assert (zeitgeist_event_get_payload (ev) == NULL); | 102 | g_assert (zeitgeist_event_get_payload (ev) == NULL); |
365 | 99 | 103 | ||
366 | @@ -105,6 +109,7 @@ | |||
367 | 105 | g_assert_cmpstr ("http://example.com", ==, zeitgeist_subject_get_origin (su)); | 109 | g_assert_cmpstr ("http://example.com", ==, zeitgeist_subject_get_origin (su)); |
368 | 106 | g_assert_cmpstr ("example.com", ==, zeitgeist_subject_get_text (su)); | 110 | g_assert_cmpstr ("example.com", ==, zeitgeist_subject_get_text (su)); |
369 | 107 | g_assert_cmpstr ("net", ==, zeitgeist_subject_get_storage (su)); | 111 | g_assert_cmpstr ("net", ==, zeitgeist_subject_get_storage (su)); |
370 | 112 | g_assert_cmpstr ("http://current-example.com", ==, zeitgeist_subject_get_current_uri (su)); | ||
371 | 108 | 113 | ||
372 | 109 | su = zeitgeist_event_get_subject (ev, 1); | 114 | su = zeitgeist_event_get_subject (ev, 1); |
373 | 110 | g_assert (zeitgeist_subject_get_uri(su) == NULL); | 115 | g_assert (zeitgeist_subject_get_uri(su) == NULL); |
374 | @@ -114,6 +119,7 @@ | |||
375 | 114 | g_assert (zeitgeist_subject_get_origin (su) == NULL); | 119 | g_assert (zeitgeist_subject_get_origin (su) == NULL); |
376 | 115 | g_assert (zeitgeist_subject_get_text (su) == NULL); | 120 | g_assert (zeitgeist_subject_get_text (su) == NULL); |
377 | 116 | g_assert (zeitgeist_subject_get_storage (su) == NULL); | 121 | g_assert (zeitgeist_subject_get_storage (su) == NULL); |
378 | 122 | g_assert (zeitgeist_subject_get_current_uri (su) == NULL); | ||
379 | 117 | 123 | ||
380 | 118 | g_object_unref (ev); | 124 | g_object_unref (ev); |
381 | 119 | } | 125 | } |
382 | @@ -151,6 +157,7 @@ | |||
383 | 151 | g_variant_builder_add (&b, "s", ZEITGEIST_ZG_ACCESS_EVENT); | 157 | g_variant_builder_add (&b, "s", ZEITGEIST_ZG_ACCESS_EVENT); |
384 | 152 | g_variant_builder_add (&b, "s", ZEITGEIST_ZG_USER_ACTIVITY); | 158 | g_variant_builder_add (&b, "s", ZEITGEIST_ZG_USER_ACTIVITY); |
385 | 153 | g_variant_builder_add (&b, "s", "application://foo.desktop"); | 159 | g_variant_builder_add (&b, "s", "application://foo.desktop"); |
386 | 160 | g_variant_builder_add (&b, "s", "origin"); | ||
387 | 154 | g_variant_builder_close (&b); | 161 | g_variant_builder_close (&b); |
388 | 155 | 162 | ||
389 | 156 | /* Build subjects */ | 163 | /* Build subjects */ |
390 | @@ -164,6 +171,7 @@ | |||
391 | 164 | g_variant_builder_add (&b, "s", "text/plain"); | 171 | g_variant_builder_add (&b, "s", "text/plain"); |
392 | 165 | g_variant_builder_add (&b, "s", "foo.txt"); | 172 | g_variant_builder_add (&b, "s", "foo.txt"); |
393 | 166 | g_variant_builder_add (&b, "s", "36e5604e-7e1b-4ebd-bb6a-184c6ea99627"); | 173 | g_variant_builder_add (&b, "s", "36e5604e-7e1b-4ebd-bb6a-184c6ea99627"); |
394 | 174 | g_variant_builder_add (&b, "s", "file:///tmp/current.txt"); | ||
395 | 167 | g_variant_builder_close (&b); | 175 | g_variant_builder_close (&b); |
396 | 168 | } | 176 | } |
397 | 169 | g_variant_builder_close (&b); | 177 | g_variant_builder_close (&b); |
398 | @@ -183,6 +191,7 @@ | |||
399 | 183 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (ev)); | 191 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (ev)); |
400 | 184 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (ev)); | 192 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (ev)); |
401 | 185 | g_assert_cmpstr ("application://foo.desktop", ==, zeitgeist_event_get_actor (ev)); | 193 | g_assert_cmpstr ("application://foo.desktop", ==, zeitgeist_event_get_actor (ev)); |
402 | 194 | g_assert_cmpstr ("origin", ==, zeitgeist_event_get_origin (ev)); | ||
403 | 186 | g_assert_cmpint (1, ==, zeitgeist_event_num_subjects (ev)); | 195 | g_assert_cmpint (1, ==, zeitgeist_event_num_subjects (ev)); |
404 | 187 | 196 | ||
405 | 188 | su = zeitgeist_event_get_subject (ev, 0); | 197 | su = zeitgeist_event_get_subject (ev, 0); |
406 | @@ -193,6 +202,7 @@ | |||
407 | 193 | g_assert_cmpstr ("file:///tmp", ==, zeitgeist_subject_get_origin (su)); | 202 | g_assert_cmpstr ("file:///tmp", ==, zeitgeist_subject_get_origin (su)); |
408 | 194 | g_assert_cmpstr ("foo.txt", ==, zeitgeist_subject_get_text (su)); | 203 | g_assert_cmpstr ("foo.txt", ==, zeitgeist_subject_get_text (su)); |
409 | 195 | g_assert_cmpstr ("36e5604e-7e1b-4ebd-bb6a-184c6ea99627", ==, zeitgeist_subject_get_storage (su)); | 204 | g_assert_cmpstr ("36e5604e-7e1b-4ebd-bb6a-184c6ea99627", ==, zeitgeist_subject_get_storage (su)); |
410 | 205 | g_assert_cmpstr ("file:///tmp/current.txt", ==, zeitgeist_subject_get_current_uri (su)); | ||
411 | 196 | 206 | ||
412 | 197 | payload = zeitgeist_event_get_payload (ev); | 207 | payload = zeitgeist_event_get_payload (ev); |
413 | 198 | g_assert (payload != NULL); | 208 | g_assert (payload != NULL); |
414 | @@ -218,6 +228,7 @@ | |||
415 | 218 | g_assert (zeitgeist_event_get_interpretation (marshalled) == NULL); | 228 | g_assert (zeitgeist_event_get_interpretation (marshalled) == NULL); |
416 | 219 | g_assert (zeitgeist_event_get_manifestation (marshalled) == NULL); | 229 | g_assert (zeitgeist_event_get_manifestation (marshalled) == NULL); |
417 | 220 | g_assert (zeitgeist_event_get_actor (marshalled) == NULL); | 230 | g_assert (zeitgeist_event_get_actor (marshalled) == NULL); |
418 | 231 | g_assert (zeitgeist_event_get_origin (marshalled) == NULL); | ||
419 | 221 | g_assert_cmpint (0, ==, zeitgeist_event_num_subjects (marshalled)); | 232 | g_assert_cmpint (0, ==, zeitgeist_event_num_subjects (marshalled)); |
420 | 222 | g_assert (zeitgeist_event_get_payload (marshalled) == NULL); | 233 | g_assert (zeitgeist_event_get_payload (marshalled) == NULL); |
421 | 223 | 234 | ||
422 | @@ -237,13 +248,15 @@ | |||
423 | 237 | ZEITGEIST_ZG_ACCESS_EVENT, | 248 | ZEITGEIST_ZG_ACCESS_EVENT, |
424 | 238 | ZEITGEIST_ZG_USER_ACTIVITY, | 249 | ZEITGEIST_ZG_USER_ACTIVITY, |
425 | 239 | "application://firefox.desktop", | 250 | "application://firefox.desktop", |
426 | 251 | "origin", | ||
427 | 240 | zeitgeist_subject_new_full ("http://example.com", | 252 | zeitgeist_subject_new_full ("http://example.com", |
428 | 241 | ZEITGEIST_NFO_WEBSITE, | 253 | ZEITGEIST_NFO_WEBSITE, |
429 | 242 | ZEITGEIST_NFO_REMOTE_DATA_OBJECT, | 254 | ZEITGEIST_NFO_REMOTE_DATA_OBJECT, |
430 | 243 | "text/html", | 255 | "text/html", |
431 | 244 | "http://example.com", | 256 | "http://example.com", |
432 | 245 | "example.com", | 257 | "example.com", |
434 | 246 | "net"), | 258 | "net", |
435 | 259 | "http://current-example.com"), | ||
436 | 247 | NULL); | 260 | NULL); |
437 | 248 | payload = g_byte_array_new (); | 261 | payload = g_byte_array_new (); |
438 | 249 | byte = 255; | 262 | byte = 255; |
439 | @@ -257,6 +270,7 @@ | |||
440 | 257 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (marshalled)); | 270 | g_assert_cmpstr (ZEITGEIST_ZG_ACCESS_EVENT,==, zeitgeist_event_get_interpretation (marshalled)); |
441 | 258 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (marshalled)); | 271 | g_assert_cmpstr (ZEITGEIST_ZG_USER_ACTIVITY, ==, zeitgeist_event_get_manifestation (marshalled)); |
442 | 259 | g_assert_cmpstr ("application://firefox.desktop", ==, zeitgeist_event_get_actor (marshalled)); | 272 | g_assert_cmpstr ("application://firefox.desktop", ==, zeitgeist_event_get_actor (marshalled)); |
443 | 273 | g_assert_cmpstr ("origin", ==, zeitgeist_event_get_origin (marshalled)); | ||
444 | 260 | g_assert_cmpint (1, ==, zeitgeist_event_num_subjects (marshalled)); | 274 | g_assert_cmpint (1, ==, zeitgeist_event_num_subjects (marshalled)); |
445 | 261 | 275 | ||
446 | 262 | payload = zeitgeist_event_get_payload (marshalled); | 276 | payload = zeitgeist_event_get_payload (marshalled); |
447 | @@ -272,6 +286,7 @@ | |||
448 | 272 | g_assert_cmpstr ("http://example.com", ==, zeitgeist_subject_get_origin (su)); | 286 | g_assert_cmpstr ("http://example.com", ==, zeitgeist_subject_get_origin (su)); |
449 | 273 | g_assert_cmpstr ("example.com", ==, zeitgeist_subject_get_text (su)); | 287 | g_assert_cmpstr ("example.com", ==, zeitgeist_subject_get_text (su)); |
450 | 274 | g_assert_cmpstr ("net", ==, zeitgeist_subject_get_storage (su)); | 288 | g_assert_cmpstr ("net", ==, zeitgeist_subject_get_storage (su)); |
451 | 289 | g_assert_cmpstr ("http://current-example.com", ==, zeitgeist_subject_get_current_uri (su)); | ||
452 | 275 | 290 | ||
453 | 276 | g_object_unref (orig); | 291 | g_object_unref (orig); |
454 | 277 | g_object_unref (marshalled); | 292 | g_object_unref (marshalled); |
Awesome work! The code looks good at a glance. I'll do a thorough review later today and run the tests to give it a final +1.