Merge lp:~tiagosh/telepathy-ofono/fix-mc-plugin-sim-labels into lp:telepathy-ofono

Proposed by Tiago Salem Herrmann
Status: Merged
Approved by: Gustavo Pichorim Boiko
Approved revision: 145
Merged at revision: 142
Proposed branch: lp:~tiagosh/telepathy-ofono/fix-mc-plugin-sim-labels
Merge into: lp:telepathy-ofono
Diff against target: 80 lines (+32/-1)
2 files modified
debian/control (+1/-1)
mc-plugin/mcp-account-manager-ofono.c (+31/-0)
To merge this branch: bzr merge lp:~tiagosh/telepathy-ofono/fix-mc-plugin-sim-labels
Reviewer Review Type Date Requested Status
Gustavo Pichorim Boiko (community) Approve
PS Jenkins bot continuous-integration Approve
Review via email: mp+260777@code.launchpad.net

Commit message

Set account display name in gsettings if empty.

Description of the change

Set account display name in gsettings if empty.

--Checklist--
Are there any related MPs required for this MP to build/function as expected? Please list.
No

Is your branch in sync with latest trunk (e.g. bzr pull lp:trunk -> no changes)
Yes

Did you perform an exploratory manual test run of your code change and any related functionality on device or emulator?
Yes

Did you successfully run all tests found in your component's Test Plan (https://wiki.ubuntu.com/Process/Merges/TestPlan/<package-name>) on device or emulator?
Yes

If you changed the UI, was the change specified/approved by design?
N/A

If you changed UI labels, did you update the pot file?
N/A

If you changed the packaging (debian), did you add a core-dev as a reviewer to this MP?
N/A

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

24 + sprintf(sim_name, "SIM %d", index+1);

We need to get this string translated to be consistent with what ofono-setup was doing.

review: Needs Fixing
143. By Tiago Salem Herrmann

get translations for sim labels

144. By Tiago Salem Herrmann

add comments

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

57 + final_sim_name = sim_name;

I think you need to strdup() the string here so that when you:
62 + free(final_sim_name);

you don't free static allocated memory.

review: Needs Fixing
145. By Tiago Salem Herrmann

use strdup so free() doesn't crash

Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Approve (continuous-integration)
Revision history for this message
Gustavo Pichorim Boiko (boiko) wrote :

Did you perform an exploratory manual test run of the code change and any related functionality on device or emulator?
Yes

Did CI run pass? If not, please explain why.
Yes

Have you checked that submitter has accurately filled out the submitter checklist and has taken no shortcut?
Yes

Code looks good and works as expected!

review: Approve
146. By Tiago Salem Herrmann

Only build on armhf, amd64 and i386

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'debian/control'
2--- debian/control 2015-05-08 20:48:08 +0000
3+++ debian/control 2015-06-03 18:56:24 +0000
4@@ -36,7 +36,7 @@
5 real phone calls and send and receive SMSs.
6
7 Package: telepathy-ofono-ril-mc-plugin
8-Architecture: any
9+Architecture: amd64 i386 armhf
10 Depends: telepathy-ofono,
11 ${misc:Depends},
12 ${shlibs:Depends},
13
14=== modified file 'mc-plugin/mcp-account-manager-ofono.c'
15--- mc-plugin/mcp-account-manager-ofono.c 2015-05-19 14:32:02 +0000
16+++ mc-plugin/mcp-account-manager-ofono.c 2015-06-03 18:56:24 +0000
17@@ -21,8 +21,11 @@
18 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 */
20
21+#include <libintl.h>
22+#include <locale.h>
23 #include <string.h>
24 #include <stdio.h>
25+#include <malloc.h>
26 #include "mcp-account-manager-ofono.h"
27
28 #define PLUGIN_NAME "ofono-account"
29@@ -74,6 +77,7 @@
30 int num_modems = 0;
31 int index;
32
33+ setlocale(LC_ALL, "");
34 self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, MCP_TYPE_ACCOUNT_MANAGER_OFONO,
35 McpAccountManagerOfonoPrivate);
36
37@@ -127,16 +131,43 @@
38 if (sim_names) {
39 GVariantIter iter;
40 GVariant *value;
41+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
42 gchar *key;
43+ int found = 0;
44
45 g_variant_iter_init (&iter, sim_names);
46 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
47+ g_variant_builder_add(builder, "(ss)", key, value);
48 if (!strcmp(key, ril_modem)) {
49 g_hash_table_insert(account->params, g_strdup("DisplayName"), g_strdup((char *)value));
50+ found = 1;
51 }
52 g_free (key);
53 g_free (value);
54 }
55+ if (!found) {
56+ char *sim_name = dgettext("telephony-service", "SIM %1");
57+ char *final_sim_name = NULL;
58+ char sim_index[10] = {0};
59+ const char *placeholder = "%1";
60+ sprintf(sim_index, "%d", index+1);
61+ const char *pos = strstr(sim_name, placeholder);
62+ if (pos) {
63+ // this is used to replace %1 by the actual index
64+ // FIXME: change telephony-service's string to %d to make everything easier
65+ final_sim_name = calloc(1, strlen(sim_name) - strlen(placeholder) + strlen(sim_index) + 1);
66+ strncpy(final_sim_name, sim_name, pos - sim_name);
67+ strcat(final_sim_name, sim_index);
68+ strcat(final_sim_name, pos + strlen(placeholder));
69+ } else {
70+ final_sim_name = strdup(sim_name);
71+ }
72+
73+ g_hash_table_insert(account->params, g_strdup("DisplayName"), g_strdup(final_sim_name));
74+ g_settings_set_value(settings, "sim-names", g_variant_new("a(ss)", builder));
75+ free(final_sim_name);
76+ }
77+ g_variant_builder_unref(builder);
78 }
79 if (sim_names) {
80 g_variant_unref(sim_names);

Subscribers

People subscribed via source and target branches