}  if (PREF_BoolPrefChanged(prefs, "security.enable_tls", tlson)) { rv = ssm_set_pack_bool_pref(prefs, "security.enable_tls", tlson, (SetPrefElement*)list, &n); SSL_EnableDefault(SSL_ENABLE_TLS, tlson);
SSMSecurityAdvisorContext_SavePrefs(SSMSecurityAdvisorContext* cx,                                    HTTPRequest* req){    SSMStatus rv;    SSMControlConnection* ctrl = NULL;    PrefSet* prefs = NULL;    PRBool ssl2on;    PRBool ssl3on;    PRBool autoSelect;    PRBool warnEnterSecure;    PRBool warnLeaveSecure;    PRBool warnViewMixed;    PRBool warnSubmitInsecure;    PRBool encryptMail;    PRBool signMail;    PRBool signNews;    char* autoStr = NULL;    char* defaultCert = NULL;    SetPrefElement list[ITEMS_MAX];    SetPrefListMessage request;    PRIntn n = 0;    /* counter */    int i;    CMTItem message;    PR_ASSERT(cx != NULL && cx->super.m_connection != NULL &&              cx->super.m_connection->m_prefs != NULL);    ctrl = cx->super.m_connection;    prefs = ctrl->m_prefs;    /* retrieve pref values */    rv = SSMSecurityAdvisor_get_bool_value(req, SSL2_SPK, &ssl2on);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, SSL3_SPK, &ssl3on);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, CLIENT_AUTH_SPK, &autoSelect);    if (rv != SSM_SUCCESS) {        goto loser;    }    if (autoSelect == PR_TRUE) {        autoStr = "Select Automatically";    }    else {        autoStr = "Ask Every Time";    }    rv = SSM_HTTPParamValue(req, EMAIL_CERT_SPK, &defaultCert);    if (defaultCert[0] == '\0') {        defaultCert = NULL;        rv = SSM_SUCCESS;    }    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, WARN_ENTER_SECURE_SPK,                                           &warnEnterSecure);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, WARN_LEAVE_SECURE_SPK,                                           &warnLeaveSecure);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, WARN_VIEW_MIXED_SPK,                                           &warnViewMixed);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, WARN_SUBMIT_INSECURE_SPK,                                           &warnSubmitInsecure);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, ENCRYPT_MAIL_SPK,                                            &encryptMail);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, SIGN_MAIL_SPK, &signMail);    if (rv != SSM_SUCCESS) {        goto loser;    }    rv = SSMSecurityAdvisor_get_bool_value(req, SIGN_NEWS_SPK, &signNews);    if (rv != SSM_SUCCESS) {        goto loser;    }    /* commit the changes */    if (PREF_BoolPrefChanged(prefs, "security.enable_ssl2", ssl2on)) {        /* value has changed */        rv = ssm_set_pack_bool_pref(prefs, "security.enable_ssl2", ssl2on,                                    (SetPrefElement*)list, &n);        SSL_EnableDefault(SSL_ENABLE_SSL2, ssl2on);    }    if (PREF_BoolPrefChanged(prefs, "security.enable_ssl3", ssl3on)) {        rv = ssm_set_pack_bool_pref(prefs, "security.enable_ssl3", ssl3on,                                    (SetPrefElement*)list, &n);        SSL_EnableDefault(SSL_ENABLE_SSL3, ssl3on);    }    if (PREF_StringPrefChanged(prefs, "security.default_personal_cert",                                autoStr)) {        rv = PREF_SetStringPref(prefs, "security.default_personal_cert",                                 autoStr);                list[n].key = PL_strdup("security.default_personal_cert");        list[n].type = STRING_PREF;        list[n].value = PL_strdup(autoStr);        n++;    }        if (PREF_StringPrefChanged(prefs, "security.default_mail_cert",                               defaultCert)) {        rv = PREF_SetStringPref(prefs, "security.default_mail_cert",                                 defaultCert);        list[n].key = PL_strdup("security.default_mail_cert");        list[n].type = STRING_PREF;        list[n].value = PL_strdup(defaultCert);        n++;    }    if (PREF_BoolPrefChanged(prefs, "security.warn_entering_secure",                              warnEnterSecure)) {        rv = ssm_set_pack_bool_pref(prefs, "security.warn_entering_secure",                                    warnEnterSecure, (SetPrefElement*)list,                                    &n);    }    if (PREF_BoolPrefChanged(prefs, "security.warn_leaving_secure",                              warnLeaveSecure)) {        rv = ssm_set_pack_bool_pref(prefs, "security.warn_leaving_secure",                                    warnLeaveSecure, (SetPrefElement*)list,                                    &n);    }    if (PREF_BoolPrefChanged(prefs, "security.warn_viewing_mixed",                              warnViewMixed)) {        rv = ssm_set_pack_bool_pref(prefs, "security.warn_viewing_mixed",                                    warnViewMixed, (SetPrefElement*)list, &n);    }    if (PREF_BoolPrefChanged(prefs, "security.warn_submit_insecure",                              warnSubmitInsecure)) {        rv = ssm_set_pack_bool_pref(prefs, "security.warn_submit_insecure",                                    warnSubmitInsecure, (SetPrefElement*)list,                                    &n);    }    if (PREF_BoolPrefChanged(prefs, "mail.encrypt_outgoing_mail",                              encryptMail)) {        rv = ssm_set_pack_bool_pref(prefs, "mail.encrypt_outgoing_mail",                                    encryptMail, (SetPrefElement*)list, &n);    }    if (PREF_BoolPrefChanged(prefs, "mail.crypto_sign_outgoing_mail",                              signMail)) {        rv = ssm_set_pack_bool_pref(prefs, "mail.crypto_sign_outgoing_mail",                                    signMail, (SetPrefElement*)list, &n);    }    if (PREF_BoolPrefChanged(prefs, "mail.crypto_sign_outgoing_news",                              signNews)) {        rv = ssm_set_pack_bool_pref(prefs, "mail.crypto_sign_outgoing_news",                                    signNews, (SetPrefElement*)list, &n);    }    rv = SSM_HTTPDefaultCommandHandler(req);    if (rv != PR_SUCCESS) {        goto loser;    }    /* finally, send the changes to the plugin so that it can save the     * changes     */    if (n > 0) {        /* we need to send this event only if prefs changed */        request.length = n;        request.list = list;        message.type = SSM_EVENT_MESSAGE | SSM_SAVE_PREF_EVENT;        if (CMT_EncodeMessage(SetPrefListMessageTemplate, &message,                               &request) != CMTSuccess) {            goto loser;        }        /* send the message through the control out queue */        SSM_SendQMessage(ctrl->m_controlOutQ, SSM_PRIORITY_NORMAL,                          message.type, message.len, (char*)message.data,                         PR_TRUE);    }loser:    /* clean out list */    for (i = 0; i < n; i++) {        if (list[i].key != NULL) {            PR_Free(list[i].key);        }        if (list[i].value != NULL) {            PR_Free(list[i].value);        }    }    return rv;}