Merge lp:~knitzsche/telegram-app/recent-keyword-aggreagation into lp:telegram-app/app

Proposed by Kyle Nitzsche
Status: Merged
Approved by: Roberto Mier Escandon
Approved revision: 110
Merged at revision: 108
Proposed branch: lp:~knitzsche/telegram-app/recent-keyword-aggreagation
Merge into: lp:telegram-app/app
Diff against target: 459 lines (+82/-218)
8 files modified
.bzrignore (+4/-1)
po/com.ubuntu.telegram.pot (+1/-1)
scope/data/com.ubuntu.telegram_sctelegram.ini (+1/-0)
scope/data/scope.ini.in (+1/-0)
scope/po/Makefile (+0/-167)
scope/po/cmake_install.cmake (+0/-46)
scope/src/query.cpp (+72/-3)
scope/src/query.h (+3/-0)
To merge this branch: bzr merge lp:~knitzsche/telegram-app/recent-keyword-aggreagation
Reviewer Review Type Date Requested Status
Roberto Mier Escandon (community) Approve
Michał Karnicki (community) Needs Fixing
Review via email: mp+260871@code.launchpad.net

Description of the change

this vivid branch supports keyword aggregation (introduced in vivid) of telegram scope by "recent" keyword using the components and result fields expected by "recent"" aggregation. The one most recent result is returned when being aggregated by "recent" keyword.

To post a comment you must log in.
Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

by the way, generated (c)make files are not ignored in bzr and thus (unexpectedly to me) they show up here in the diff. The only files that really matter to this MR's functionality are scope.ini.in, query.cpp and query.h. cheers

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Why scope/po/Makefile and scope/po/cmake_install.cmake are in the repository. Should they be ignored instead?
In any case, they have abs path to your local folders :S

review: Needs Fixing
Revision history for this message
Michał Karnicki (karni) wrote :

I am aware that current scope source may not be super clean, but let's try to make it better.

I would have the following suggestions:
0) what Roberto said - it's less about the local paths present, more about some noise in this MP's diff
1) rename md_ to mMetaData (to follow rest of member fields, like mScopeDir)
2) stick to one convention - camel case, I see recentMessages, agged_by_recent and totalunread:
+ auto recentMessages = reply->register_category("telegram_recent", "Telegram", "", catRecentRendr);
[...]
+ if (!agged_by_recent && totalunread > 0 && search_query.isEmpty()) {
Yes I'm aware two of these where already there in this form, let's just focus on making it better. Feel free to also s/totalunread/totalUnread
3) please open blocks of code with brace on same line, and feel free to put lone 'break;'s on same line as if conditions, if you want - if not, please wrap in { }
4) instead of:
    for (unsigned int i = 0; i < results.size(); i++)
    {
        if (agged_by_recent)
        {
        // huge block here
        break;
        reply->push(results[i]);
    }
I would suggest the following, which should improve readability:
    if (agged_by_recent) {
        // do stuff here
        return;
    }
    for (...) {
        reply->push(results[i]);
    }

I think this would be solid. The new logic looks sane.

review: Needs Fixing
Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

Just a comment for Karni:
C++ 11 uses this_annotation and Qt uses thisOther ... so... it's not easy agree on one of them since everybody is right regardless of what his opinion is.

In fw we have the next "convention" for everybody to be happy:

- all c++ 11 related code uses underscore annotation
- all Qt related code uses camel case

so that you can have instructions like:

const std::atype& a_var = "a value";
const QVariant &another = QVariant("another");
QString myString = QString::fromStdString(one_object.calling_any_c_eleven_method(a_var, another));

besides, in scopes world the usual way you find code is in c++ 11 way, so that annotation can't be skipped

Revision history for this message
Michał Karnicki (karni) wrote :

Thank you for your feedback, Roberto. To be clear, I'm not in favor of one of those. I'm simply in favor of consistency :) I don't mind if the rest is converted to use underscore notation, as long as we try to be consistent. (Regardless, for instance, the md_ is neither descriptive nor consistent with any other member in that source. Perhaps meta_data would be better, if all other variables/members weren't camel case.)

Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

Thanks guys.
New branch about to be posted. Responses to comments above:
0) I have bzr ignored the po/ cmake/make files. (seems odd that I should need to do this since I have not modified any build scripts or introduced new terms for l10n... but c'est la vie :)
1) have changed md_ to mMetadata (not mMetaData since the api uses a lower case 'd'.
2) have changed agged_by_recent to aggedByRecent
3) & 4) I open blocks on the same line
cheers - Kyle

109. By Kyle Nitzsche

modified code conventions to fit this project per MR request

Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

hang on, the Makefile and cmake files are still present

110. By Kyle Nitzsche

bzr ignore scope/po/Makefile & scope/po/cmake_install.cmake

Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

OK, I removed and ignored the scope/po/ make files

Revision history for this message
Roberto Mier Escandon (rmescandon) wrote :

lgtm (though not tested)

review: Approve
Revision history for this message
Kyle Nitzsche (knitzsche) wrote :

Roberto, can you top approve pls? Looks like karni is on holiday.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file '.bzrignore'
2--- .bzrignore 2015-05-11 08:49:51 +0000
3+++ .bzrignore 2015-06-03 13:43:06 +0000
4@@ -13,8 +13,9 @@
5 third_party
6 telegram
7 telegram_automoc.cpp
8-
9 Makefile
10+po/Makefile
11+po/cmake_install.cmake
12 CMakeLists.txt.user
13 CMakeFiles
14 CMakeCache.txt
15@@ -34,3 +35,5 @@
16 scope/src/com.ubuntu.telegram_sctelegram_automoc.cpp
17 .ycm_extra_conf.py
18 scope/po/built_mos
19+scope/po/Makefile
20+scope/po/cmake_install.cmake
21
22=== modified file 'po/com.ubuntu.telegram.pot'
23--- po/com.ubuntu.telegram.pot 2015-06-01 15:01:21 +0000
24+++ po/com.ubuntu.telegram.pot 2015-06-03 13:43:06 +0000
25@@ -8,7 +8,7 @@
26 msgstr ""
27 "Project-Id-Version: \n"
28 "Report-Msgid-Bugs-To: \n"
29-"POT-Creation-Date: 2015-06-01 17:00+0200\n"
30+"POT-Creation-Date: 2015-06-03 09:40-0400\n"
31 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
32 "Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
33 "Language-Team: LANGUAGE <LL@li.org>\n"
34
35=== modified file 'scope/data/com.ubuntu.telegram_sctelegram.ini'
36--- scope/data/com.ubuntu.telegram_sctelegram.ini 2015-06-01 15:01:21 +0000
37+++ scope/data/com.ubuntu.telegram_sctelegram.ini 2015-06-03 13:43:06 +0000
38@@ -68,6 +68,7 @@
39 SearchHint[uk]=Шукати повідомлення
40 SearchHint[zh_TW]=搜尋訊息
41 HotKey=tasks.HotKey
42+Keywords=recent
43 [Appearance]
44 background=color:///#497495
45 PageHeader.Logo=./images/logo.png
46
47=== modified file 'scope/data/scope.ini.in'
48--- scope/data/scope.ini.in 2014-12-02 12:35:48 +0000
49+++ scope/data/scope.ini.in 2015-06-03 13:43:06 +0000
50@@ -6,6 +6,7 @@
51 Icon=./images/telegram.png
52 _SearchHint=Search for a message
53 HotKey=tasks.HotKey
54+Keywords=recent
55 [Appearance]
56 background=color:///#497495
57 PageHeader.Logo=./images/logo.png
58
59=== removed file 'scope/po/Makefile'
60--- scope/po/Makefile 2015-04-15 08:59:54 +0000
61+++ scope/po/Makefile 1970-01-01 00:00:00 +0000
62@@ -1,167 +0,0 @@
63-# CMAKE generated file: DO NOT EDIT!
64-# Generated by "Unix Makefiles" Generator, CMake Version 2.8
65-
66-# Default target executed when no arguments are given to make.
67-default_target: all
68-.PHONY : default_target
69-
70-#=============================================================================
71-# Special targets provided by cmake.
72-
73-# Disable implicit rules so canonical targets will work.
74-.SUFFIXES:
75-
76-# Remove some rules from gmake that .SUFFIXES does not remove.
77-SUFFIXES =
78-
79-.SUFFIXES: .hpux_make_needs_suffix_list
80-
81-# Suppress display of executed commands.
82-$(VERBOSE).SILENT:
83-
84-# A target that is always out of date.
85-cmake_force:
86-.PHONY : cmake_force
87-
88-#=============================================================================
89-# Set environment variables for the build.
90-
91-# The shell in which to execute make rules.
92-SHELL = /bin/sh
93-
94-# The CMake executable.
95-CMAKE_COMMAND = /usr/bin/cmake
96-
97-# The command to remove a file.
98-RM = /usr/bin/cmake -E remove -f
99-
100-# Escaping for special characters.
101-EQUALS = =
102-
103-# The top-level source directory on which CMake was run.
104-CMAKE_SOURCE_DIR = /home/karni/src/canonical/telegram/app
105-
106-# The top-level build directory on which CMake was run.
107-CMAKE_BINARY_DIR = /home/karni/src/canonical/telegram/app
108-
109-#=============================================================================
110-# Targets provided globally by CMake.
111-
112-# Special rule for the target edit_cache
113-edit_cache:
114- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running interactive CMake command-line interface..."
115- /usr/bin/cmake -i .
116-.PHONY : edit_cache
117-
118-# Special rule for the target edit_cache
119-edit_cache/fast: edit_cache
120-.PHONY : edit_cache/fast
121-
122-# Special rule for the target install
123-install: preinstall
124- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
125- /usr/bin/cmake -P cmake_install.cmake
126-.PHONY : install
127-
128-# Special rule for the target install
129-install/fast: preinstall/fast
130- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Install the project..."
131- /usr/bin/cmake -P cmake_install.cmake
132-.PHONY : install/fast
133-
134-# Special rule for the target install/local
135-install/local: preinstall
136- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing only the local directory..."
137- /usr/bin/cmake -DCMAKE_INSTALL_LOCAL_ONLY=1 -P cmake_install.cmake
138-.PHONY : install/local
139-
140-# Special rule for the target install/local
141-install/local/fast: install/local
142-.PHONY : install/local/fast
143-
144-# Special rule for the target install/strip
145-install/strip: preinstall
146- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Installing the project stripped..."
147- /usr/bin/cmake -DCMAKE_INSTALL_DO_STRIP=1 -P cmake_install.cmake
148-.PHONY : install/strip
149-
150-# Special rule for the target install/strip
151-install/strip/fast: install/strip
152-.PHONY : install/strip/fast
153-
154-# Special rule for the target list_install_components
155-list_install_components:
156- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Available install components are: \"Unspecified\""
157-.PHONY : list_install_components
158-
159-# Special rule for the target list_install_components
160-list_install_components/fast: list_install_components
161-.PHONY : list_install_components/fast
162-
163-# Special rule for the target rebuild_cache
164-rebuild_cache:
165- @$(CMAKE_COMMAND) -E cmake_echo_color --switch=$(COLOR) --cyan "Running CMake to regenerate build system..."
166- /usr/bin/cmake -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR)
167-.PHONY : rebuild_cache
168-
169-# Special rule for the target rebuild_cache
170-rebuild_cache/fast: rebuild_cache
171-.PHONY : rebuild_cache/fast
172-
173-# The main all target
174-all: cmake_check_build_system
175- cd /home/karni/src/canonical/telegram/app && $(CMAKE_COMMAND) -E cmake_progress_start /home/karni/src/canonical/telegram/app/CMakeFiles /home/karni/src/canonical/telegram/app/scope/po/CMakeFiles/progress.marks
176- cd /home/karni/src/canonical/telegram/app && $(MAKE) -f CMakeFiles/Makefile2 scope/po/all
177- $(CMAKE_COMMAND) -E cmake_progress_start /home/karni/src/canonical/telegram/app/CMakeFiles 0
178-.PHONY : all
179-
180-# The main clean target
181-clean:
182- cd /home/karni/src/canonical/telegram/app && $(MAKE) -f CMakeFiles/Makefile2 scope/po/clean
183-.PHONY : clean
184-
185-# The main clean target
186-clean/fast: clean
187-.PHONY : clean/fast
188-
189-# Prepare targets for installation.
190-preinstall: all
191- cd /home/karni/src/canonical/telegram/app && $(MAKE) -f CMakeFiles/Makefile2 scope/po/preinstall
192-.PHONY : preinstall
193-
194-# Prepare targets for installation.
195-preinstall/fast:
196- cd /home/karni/src/canonical/telegram/app && $(MAKE) -f CMakeFiles/Makefile2 scope/po/preinstall
197-.PHONY : preinstall/fast
198-
199-# clear depends
200-depend:
201- cd /home/karni/src/canonical/telegram/app && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 1
202-.PHONY : depend
203-
204-# Help Target
205-help:
206- @echo "The following are some of the valid targets for this Makefile:"
207- @echo "... all (the default if no target is provided)"
208- @echo "... clean"
209- @echo "... depend"
210- @echo "... edit_cache"
211- @echo "... install"
212- @echo "... install/local"
213- @echo "... install/strip"
214- @echo "... list_install_components"
215- @echo "... rebuild_cache"
216-.PHONY : help
217-
218-
219-
220-#=============================================================================
221-# Special targets to cleanup operation of make.
222-
223-# Special rule to run CMake to check the build system integrity.
224-# No rule that depends on this can have commands that come from listfiles
225-# because they might be regenerated.
226-cmake_check_build_system:
227- cd /home/karni/src/canonical/telegram/app && $(CMAKE_COMMAND) -H$(CMAKE_SOURCE_DIR) -B$(CMAKE_BINARY_DIR) --check-build-system CMakeFiles/Makefile.cmake 0
228-.PHONY : cmake_check_build_system
229-
230
231=== removed file 'scope/po/cmake_install.cmake'
232--- scope/po/cmake_install.cmake 2015-04-15 08:59:54 +0000
233+++ scope/po/cmake_install.cmake 1970-01-01 00:00:00 +0000
234@@ -1,46 +0,0 @@
235-# Install script for directory: /home/karni/src/canonical/telegram/app/scope/po
236-
237-# Set the install prefix
238-IF(NOT DEFINED CMAKE_INSTALL_PREFIX)
239- SET(CMAKE_INSTALL_PREFIX "/")
240-ENDIF(NOT DEFINED CMAKE_INSTALL_PREFIX)
241-STRING(REGEX REPLACE "/$" "" CMAKE_INSTALL_PREFIX "${CMAKE_INSTALL_PREFIX}")
242-
243-# Set the install configuration name.
244-IF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
245- IF(BUILD_TYPE)
246- STRING(REGEX REPLACE "^[^A-Za-z0-9_]+" ""
247- CMAKE_INSTALL_CONFIG_NAME "${BUILD_TYPE}")
248- ELSE(BUILD_TYPE)
249- SET(CMAKE_INSTALL_CONFIG_NAME "")
250- ENDIF(BUILD_TYPE)
251- MESSAGE(STATUS "Install configuration: \"${CMAKE_INSTALL_CONFIG_NAME}\"")
252-ENDIF(NOT DEFINED CMAKE_INSTALL_CONFIG_NAME)
253-
254-# Set the component getting installed.
255-IF(NOT CMAKE_INSTALL_COMPONENT)
256- IF(COMPONENT)
257- MESSAGE(STATUS "Install component: \"${COMPONENT}\"")
258- SET(CMAKE_INSTALL_COMPONENT "${COMPONENT}")
259- ELSE(COMPONENT)
260- SET(CMAKE_INSTALL_COMPONENT)
261- ENDIF(COMPONENT)
262-ENDIF(NOT CMAKE_INSTALL_COMPONENT)
263-
264-# Install shared libraries without execute permission?
265-IF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
266- SET(CMAKE_INSTALL_SO_NO_EXE "1")
267-ENDIF(NOT DEFINED CMAKE_INSTALL_SO_NO_EXE)
268-
269-IF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
270- list(APPEND CMAKE_ABSOLUTE_DESTINATION_FILES
271- "/sctelegram/locale")
272- IF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
273- message(WARNING "ABSOLUTE path INSTALL DESTINATION : ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
274- ENDIF (CMAKE_WARN_ON_ABSOLUTE_INSTALL_DESTINATION)
275- IF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
276- message(FATAL_ERROR "ABSOLUTE path INSTALL DESTINATION forbidden (by caller): ${CMAKE_ABSOLUTE_DESTINATION_FILES}")
277- ENDIF (CMAKE_ERROR_ON_ABSOLUTE_INSTALL_DESTINATION)
278-FILE(INSTALL DESTINATION "/sctelegram" TYPE DIRECTORY FILES "/home/karni/src/canonical/telegram/app/scope/po/built_mos/locale")
279-ENDIF(NOT CMAKE_INSTALL_COMPONENT OR "${CMAKE_INSTALL_COMPONENT}" STREQUAL "Unspecified")
280-
281
282=== modified file 'scope/src/query.cpp'
283--- scope/src/query.cpp 2015-02-11 12:38:39 +0000
284+++ scope/src/query.cpp 2015-06-03 13:43:06 +0000
285@@ -3,6 +3,7 @@
286 #include <unity/scopes/CategoryRenderer.h>
287 #include <unity/scopes/QueryBase.h>
288 #include <unity/scopes/SearchReply.h>
289+#include <unity/scopes/VariantBuilder.h>
290
291 #include <QDebug>
292 #include <QUrl>
293@@ -21,6 +22,25 @@
294
295 namespace
296 {
297+
298+static const std::string RECENT = R"(
299+{
300+ "schema-version": 1,
301+ "template":
302+ {
303+ "category-layout": "grid",
304+ "card-layout": "horizontal",
305+ "card-size": "large"
306+ },
307+ "components":
308+ {
309+ "title": "title",
310+ "attributes": {"field": "attributes", "max-count": 4},
311+ "mascot": "mascot"
312+ }
313+}
314+)";
315+
316 const static std::string UNREAD_TEMPLATE =
317 R"(
318 {
319@@ -154,7 +174,7 @@
320 }
321
322 TelegramQuery::TelegramQuery(CannedQuery const& query, SearchMetadata const& metadata, QString const& scopeDir) :
323- SearchQueryBase(query, metadata), mScopeDir(scopeDir)
324+ SearchQueryBase(query, metadata), mMetadata(metadata), mScopeDir(scopeDir)
325 {
326 setlocale(LC_ALL, "");
327 textdomain(GETTEXT_DOMAIN.toStdString().c_str());
328@@ -452,17 +472,26 @@
329
330 void TelegramQuery::run(unity::scopes::SearchReplyProxy const& reply)
331 {
332+ bool aggedByRecent = false;
333 unsigned int recentMax = 10;
334+ if (mMetadata.is_aggregated()){
335+ auto keywords = mMetadata.aggregated_keywords();
336+ if (keywords.find("recent") != keywords.end()){
337+ aggedByRecent = true;
338+ }
339+ }
340 //Tell gettext where to look for textdomain files
341 QString tdir = QString("%1/locale/").arg(mScopeDir);
342 QString basedir = QString(bindtextdomain(GETTEXT_DOMAIN.toStdString().c_str(), tdir.toStdString().c_str()));
343 QString search_query = QString::fromStdString(query().query_string());
344
345 CategoryRenderer catReadRendr(search_query.isEmpty()?READ_TEMPLATE:SEARCH_MESS_TEMPLATE);
346+ CategoryRenderer catRecentRendr(RECENT);
347 CategoryRenderer catUnreadRendr(UNREAD_TEMPLATE);
348 CategoryRenderer carrRendr(search_query.isEmpty()?CARR_TEMPLATE:CONTACTS_SEARCH_TEMPLATE);
349 CategoryRenderer photoRendr(PHOTO_TEMPLATE);
350
351+ auto recentMessages = reply->register_category("telegram_recent", "Telegram", "", catRecentRendr);
352 auto readMessages = reply->register_category("read", _("Recent Messages"), "", catReadRendr);
353 auto buddiesCat = reply->register_category("buddies", _("People You Talk To"), "", carrRendr);
354 auto photoCat = reply->register_category("photos", _("Received Images"), "", photoRendr);;
355@@ -485,7 +514,7 @@
356
357 auto totalunread = getUnreadMessages(myTelegram);
358
359- if (totalunread > 0 && search_query.isEmpty()) {
360+ if (!aggedByRecent && totalunread > 0 && search_query.isEmpty()) {
361 QString title_unread = _("Unread Messages: %1");
362 title_unread = title_unread.arg(totalunread);
363 auto unReadMessages = reply->register_category("unread",title_unread.toStdString(), "", catUnreadRendr);
364@@ -503,24 +532,37 @@
365 for (unsigned int i = 0 ; i < myTelegram.size(); i++){
366 if (myTelegram[i].out || unReadIds.find(myTelegram[i].id) != unReadIds.end())
367 continue;
368+ if (aggedByRecent && results.size() > 0)
369+ break;// recent keyword aggregation only wants one message
370 recieveMsgs++;
371 myBuddies[myTelegram[i].from.id] = myTelegram[i].from;
372 if (recieveMsgs <= recentMax && search_query.isEmpty()){
373 auto res = messageToResult(readMessages,myTelegram[i],false);
374 results.push_back(res);
375+ if (aggedByRecent){
376+ results.clear();// we want only the last item in the vector
377+ results.push_back(res);
378+ break;// recent keyword aggregation only wants one message
379+ }
380 }
381 if (!search_query.isEmpty() && myTelegram[i].text.contains(search_query,Qt::CaseInsensitive)){
382 auto res = messageToResult(searchReadMessages,myTelegram[i],false);
383 results.push_back(res);
384+ if (aggedByRecent)
385+ break;// recent keyword aggregation only wants one message
386 }
387 if (search_query.isEmpty() &&
388 (myTelegram[i].mediaType == MessageMediaType::typeMessageMediaPhoto ||
389 myTelegram[i].mediaType == MessageMediaType::typeMessageMediaVideo)) {
390 auto res = messageToResult(photoCat,myTelegram[i],true);
391 results.push_back(res);
392+ if (aggedByRecent)
393+ break;// recent keyword aggregation only wants one message
394 }
395 }
396 for (auto& mycontact: myBuddies) {
397+ if (aggedByRecent)
398+ break;// recent keyword aggregation only wants one message
399 if ((mycontact.second.firstName.isEmpty() && mycontact.second.lastName.isEmpty()) ||
400 mycontact.second.id == mOurId) {
401 continue;
402@@ -536,6 +578,33 @@
403 results.insert(results.begin(),res);
404 }
405 }
406- for (unsigned int i = 0; i < results.size(); i++)
407+ if (aggedByRecent){
408+ auto res = results[0];
409+ // open telegram scope instead of preview:
410+ res.set_uri("scope://com.ubuntu.telegram_sctelegram");
411+ // set up result as recent aggregation expects it
412+ std::string title = res["title"].get_string();
413+ res["title"] = res["from"];
414+ unity::scopes::VariantBuilder attrs;
415+ attrs.add_tuple({
416+ {"value", unity::scopes::Variant(title)}
417+ });
418+ attrs.add_tuple({
419+ {"value", unity::scopes::Variant("")}
420+ });
421+ attrs.add_tuple({
422+ {"value", unity::scopes::Variant(res["date"])}
423+ });
424+ attrs.add_tuple({
425+ {"value", unity::scopes::Variant("")}
426+ });
427+ res["attributes"] = attrs.end();
428+ std::string icon = QString("file://%1/images/telegram.png").arg(mScopeDir).toStdString();
429+ res["mascot"] = icon;
430+ reply->push(res);
431+ return;
432+ }
433+ for (unsigned int i = 0; i < results.size(); i++){
434 reply->push(results[i]);
435+ }
436 }
437
438=== modified file 'scope/src/query.h'
439--- scope/src/query.h 2014-12-05 14:52:19 +0000
440+++ scope/src/query.h 2015-06-03 13:43:06 +0000
441@@ -2,8 +2,10 @@
442 #define DEMOQUERY_H
443
444 #include <unity/scopes/SearchQueryBase.h>
445+#include <unity/scopes/SearchMetadata.h>
446 #include <unity/scopes/ReplyProxyFwd.h>
447 #include <unity/scopes/CategorisedResult.h>
448+#include <unity/scopes/CategorisedResult.h>
449 #include <QtSql>
450 #include <QSqlDatabase>
451 #include <QFileInfo>
452@@ -55,6 +57,7 @@
453 unity::scopes::CategorisedResult messageToResult(unity::scopes::Category::SCPtr category, TelegramMessage message,bool useAttachment);
454 unity::scopes::CategorisedResult contactToResult(unity::scopes::Category::SCPtr category, TelegramContact contact);
455 int getUnreadMessages(std::vector<TelegramMessage> & unreadMessages);
456+ unity::scopes::SearchMetadata mMetadata;
457 };
458
459 #endif

Subscribers

People subscribed via source and target branches