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
=== modified file 'debian/control'
--- debian/control 2015-05-08 20:48:08 +0000
+++ debian/control 2015-06-03 18:56:24 +0000
@@ -36,7 +36,7 @@
36 real phone calls and send and receive SMSs.36 real phone calls and send and receive SMSs.
3737
38Package: telepathy-ofono-ril-mc-plugin38Package: telepathy-ofono-ril-mc-plugin
39Architecture: any39Architecture: amd64 i386 armhf
40Depends: telepathy-ofono,40Depends: telepathy-ofono,
41 ${misc:Depends},41 ${misc:Depends},
42 ${shlibs:Depends},42 ${shlibs:Depends},
4343
=== modified file 'mc-plugin/mcp-account-manager-ofono.c'
--- mc-plugin/mcp-account-manager-ofono.c 2015-05-19 14:32:02 +0000
+++ mc-plugin/mcp-account-manager-ofono.c 2015-06-03 18:56:24 +0000
@@ -21,8 +21,11 @@
21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.21 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
22 */22 */
2323
24#include <libintl.h>
25#include <locale.h>
24#include <string.h>26#include <string.h>
25#include <stdio.h>27#include <stdio.h>
28#include <malloc.h>
26#include "mcp-account-manager-ofono.h"29#include "mcp-account-manager-ofono.h"
2730
28#define PLUGIN_NAME "ofono-account"31#define PLUGIN_NAME "ofono-account"
@@ -74,6 +77,7 @@
74 int num_modems = 0;77 int num_modems = 0;
75 int index;78 int index;
7679
80 setlocale(LC_ALL, "");
77 self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, MCP_TYPE_ACCOUNT_MANAGER_OFONO,81 self->priv = G_TYPE_INSTANCE_GET_PRIVATE(self, MCP_TYPE_ACCOUNT_MANAGER_OFONO,
78 McpAccountManagerOfonoPrivate);82 McpAccountManagerOfonoPrivate);
7983
@@ -127,16 +131,43 @@
127 if (sim_names) {131 if (sim_names) {
128 GVariantIter iter;132 GVariantIter iter;
129 GVariant *value;133 GVariant *value;
134 GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(ss)"));
130 gchar *key;135 gchar *key;
136 int found = 0;
131137
132 g_variant_iter_init (&iter, sim_names);138 g_variant_iter_init (&iter, sim_names);
133 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {139 while (g_variant_iter_next (&iter, "{ss}", &key, &value)) {
140 g_variant_builder_add(builder, "(ss)", key, value);
134 if (!strcmp(key, ril_modem)) {141 if (!strcmp(key, ril_modem)) {
135 g_hash_table_insert(account->params, g_strdup("DisplayName"), g_strdup((char *)value));142 g_hash_table_insert(account->params, g_strdup("DisplayName"), g_strdup((char *)value));
143 found = 1;
136 }144 }
137 g_free (key);145 g_free (key);
138 g_free (value);146 g_free (value);
139 }147 }
148 if (!found) {
149 char *sim_name = dgettext("telephony-service", "SIM %1");
150 char *final_sim_name = NULL;
151 char sim_index[10] = {0};
152 const char *placeholder = "%1";
153 sprintf(sim_index, "%d", index+1);
154 const char *pos = strstr(sim_name, placeholder);
155 if (pos) {
156 // this is used to replace %1 by the actual index
157 // FIXME: change telephony-service's string to %d to make everything easier
158 final_sim_name = calloc(1, strlen(sim_name) - strlen(placeholder) + strlen(sim_index) + 1);
159 strncpy(final_sim_name, sim_name, pos - sim_name);
160 strcat(final_sim_name, sim_index);
161 strcat(final_sim_name, pos + strlen(placeholder));
162 } else {
163 final_sim_name = strdup(sim_name);
164 }
165
166 g_hash_table_insert(account->params, g_strdup("DisplayName"), g_strdup(final_sim_name));
167 g_settings_set_value(settings, "sim-names", g_variant_new("a(ss)", builder));
168 free(final_sim_name);
169 }
170 g_variant_builder_unref(builder);
140 }171 }
141 if (sim_names) {172 if (sim_names) {
142 g_variant_unref(sim_names);173 g_variant_unref(sim_names);

Subscribers

People subscribed via source and target branches