<p>Joshua Colp has uploaded this change for <strong>review</strong>.</p><p><a href="https://gerrit.asterisk.org/9744">View Change</a></p><pre style="font-family: monospace,monospace; white-space: pre-wrap;">res_pjsip_pubsub: Treat "prune_on_boot" as a boolean.<br><br>The alembic for the PJSIP subscription persistence table has the<br>"prune_on_boot" field as a boolean. While in Asterisk we are<br>tolerant of many different definitions of true and false in the<br>database we only accept "yes" and "no". This change makes the<br>field treated as a boolean instead of an integer, thus storing<br>"yes" and "no" instead of "1" and "0".<br><br>The OPT_BOOL_T field type can't be used as it stores in string<br>format as "true" and "false" which is not supported by the Alembic.<br><br>Change-Id: Ic8b9211b36babefe78f70def6828a135a6ae7ab6<br>---<br>M res/res_pjsip_pubsub.c<br>1 file changed, 16 insertions(+), 2 deletions(-)<br><br></pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;">git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/44/9744/1</pre><pre style="font-family: monospace,monospace; white-space: pre-wrap;"><span>diff --git a/res/res_pjsip_pubsub.c b/res/res_pjsip_pubsub.c</span><br><span>index 2f32ebc..c04f4e2 100644</span><br><span>--- a/res/res_pjsip_pubsub.c</span><br><span>+++ b/res/res_pjsip_pubsub.c</span><br><span>@@ -4729,6 +4729,20 @@</span><br><span>      return (ast_asprintf(buf, "%ld", persistence->expires.tv_sec) < 0) ? -1 : 0;</span><br><span> }</span><br><span> </span><br><span style="color: hsl(120, 100%, 40%);">+static int persistence_prune_on_boot_str2int(const struct aco_option *opt, struct ast_variable *var, void *obj)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+     struct subscription_persistence *persistence = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+   persistence->prune_on_boot = ast_true(var->value);</span><br><span style="color: hsl(120, 100%, 40%);">+      return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span style="color: hsl(120, 100%, 40%);">+static int persistence_prune_on_boot_int2str(const void *obj, const intptr_t *args, char **buf)</span><br><span style="color: hsl(120, 100%, 40%);">+{</span><br><span style="color: hsl(120, 100%, 40%);">+    const struct subscription_persistence *persistence = obj;</span><br><span style="color: hsl(120, 100%, 40%);">+     *buf = ast_strdup(persistence->prune_on_boot ? "yes" : "no");</span><br><span style="color: hsl(120, 100%, 40%);">+  return 0;</span><br><span style="color: hsl(120, 100%, 40%);">+}</span><br><span style="color: hsl(120, 100%, 40%);">+</span><br><span> #define RESOURCE_LIST_INIT_SIZE 4</span><br><span> </span><br><span> static void resource_list_destructor(void *obj)</span><br><span>@@ -5589,8 +5603,8 @@</span><br><span>           persistence_expires_str2struct, persistence_expires_struct2str, NULL, 0, 0);</span><br><span>         ast_sorcery_object_field_register(sorcery, "subscription_persistence", "contact_uri", "", OPT_CHAR_ARRAY_T, 0,</span><br><span>                 CHARFLDSET(struct subscription_persistence, contact_uri));</span><br><span style="color: hsl(0, 100%, 40%);">-      ast_sorcery_object_field_register(sorcery, "subscription_persistence", "prune_on_boot", "0", OPT_UINT_T, 0,</span><br><span style="color: hsl(0, 100%, 40%);">-               FLDSET(struct subscription_persistence, prune_on_boot));</span><br><span style="color: hsl(120, 100%, 40%);">+      ast_sorcery_object_field_register_custom(sorcery, "subscription_persistence", "prune_on_boot", "no",</span><br><span style="color: hsl(120, 100%, 40%);">+            persistence_prune_on_boot_str2int, persistence_prune_on_boot_int2str, NULL, 0, 0);</span><br><span> </span><br><span>       if (apply_list_configuration(sorcery)) {</span><br><span>             ast_sched_context_destroy(sched);</span><br><span></span><br></pre><p>To view, visit <a href="https://gerrit.asterisk.org/9744">change 9744</a>. To unsubscribe, or for help writing mail filters, visit <a href="https://gerrit.asterisk.org/settings">settings</a>.</p><div itemscope itemtype="http://schema.org/EmailMessage"><div itemscope itemprop="action" itemtype="http://schema.org/ViewAction"><link itemprop="url" href="https://gerrit.asterisk.org/9744"/><meta itemprop="name" content="View Change"/></div></div>

<div style="display:none"> Gerrit-Project: asterisk </div>
<div style="display:none"> Gerrit-Branch: 13 </div>
<div style="display:none"> Gerrit-MessageType: newchange </div>
<div style="display:none"> Gerrit-Change-Id: Ic8b9211b36babefe78f70def6828a135a6ae7ab6 </div>
<div style="display:none"> Gerrit-Change-Number: 9744 </div>
<div style="display:none"> Gerrit-PatchSet: 1 </div>
<div style="display:none"> Gerrit-Owner: Joshua Colp <jcolp@digium.com> </div>