acs_mail_lite::imap_conn_set (private)

 acs_mail_lite::imap_conn_set [ -host host ] [ -password password ] \
    [ -port port ] [ -timeout timeout ] [ -user user ] \
    [ -name_mb name_mb ] [ -flags flags ]

Defined in packages/acs-mail-lite/tcl/imap-inbound-procs.tcl

Returns a name value list of parameters used by ACS Mail Lite imap connections If a parameter is passed with value, the value is assigned to parameter.

Switches:
-host
(optional)
-password
(optional)
-port
(optional)
Ignored for now. SSL automatically switches port.
-timeout
(optional)
-user
(optional)
-name_mb
(optional)
See nsimap documentation for mailbox.name.
-flags
(optional)

Partial Call Graph (max 5 caller/called nodes):
%3 acs_mail_lite::email_type acs_mail_lite::email_type (public) acs_mail_lite::imap_conn_set acs_mail_lite::imap_conn_set acs_mail_lite::email_type->acs_mail_lite::imap_conn_set acs_mail_lite::imap_check_incoming acs_mail_lite::imap_check_incoming (private) acs_mail_lite::imap_check_incoming->acs_mail_lite::imap_conn_set acs_mail_lite::imap_conn_go acs_mail_lite::imap_conn_go (private) acs_mail_lite::imap_conn_go->acs_mail_lite::imap_conn_set acs_mail_lite::imap_mailbox_join acs_mail_lite::imap_mailbox_join (public) acs_mail_lite::imap_conn_set->acs_mail_lite::imap_mailbox_join acs_mail_lite::imap_mailbox_split acs_mail_lite::imap_mailbox_split (public) acs_mail_lite::imap_conn_set->acs_mail_lite::imap_mailbox_split db_0or1row db_0or1row (public) acs_mail_lite::imap_conn_set->db_0or1row db_dml db_dml (public) acs_mail_lite::imap_conn_set->db_dml db_transaction db_transaction (public) acs_mail_lite::imap_conn_set->db_transaction

Testcases:
No testcase defined.
Source code:
    # See one row table acs_mail_lite_imap_conn
    # imap_conn_ = ic
    set ic_list [list  host  password  port  timeout  user  name_mb  flags]
    # ic fields = icf
    set icf_list [list ]
    foreach ic $ic_list {
        set icf [string range $ic 0 1]
        lappend icf_list $icf
        if { [info exists $ic] } {
            set new_arr(${ic}) [set $ic]
        }
    }
    set changes_p [array exists new]
    set exists_p [db_0or1row acs_mail_lite_imap_conn_r {
        select ho,pa,po,ti,us,na,fl
        from acs_mail_lite_imap_conn
        fetch first 1 rows only
    } ]

    if { !$exists_p } {
        # set initial defaults
        set mb [ns_config nsimap mailbox ""]
        set mb_good_form_p [regexp -nocase --  {^[{]([a-z0-9\.\/]+)[}]([a-z0-9\/\ \_]+)$}  $mb x ho na]
        # ho and na defined by regexp?
        set ssl_p 0
        if { !$mb_good_form_p } {
            ns_log Notice "acs_mail_lite::imap_conn_set.463.  config.tcl's mailbox '${mb}' not in good form.  Quote mailbox with curly braces like: {{mailbox.host}mailbox.name} "
            set mb_list [acs_mail_lite::imap_mailbox_split $mb]
            if { [llength $mb_list] == 3 } {
                lassign $mb_list ho na ssl_p
                ns_log Notice "acs_mail_lite::imap_conn_set.479:  Used alternate parsing. host '${ho}' mailbox.name '${na}' ssl_p '${ssl_p}'"
            } else {
                set ho [ns_config nssock hostname ""]
                if { $ho eq "" } {
                    set ho [ns_config nssock_v4 hostname ""]
                }
                if { $ho eq "" } {
                    set ho [ns_config nssock_v6 hostname ""]
                }
                set na "mail/INBOX"
                set mb [acs_mail_lite::imap_mailbox_join -host $ho -name $na]

                ns_log Notice "acs_mail_lite::imap_conn_set.482:  Using values from nsd config.tcl. host '${ho}' mailbox.name '${na}'"

            }
        }

        set pa [ns_config nsimap password ""]
        set po [ns_config nsimap port ""]
        set ti [ns_config -int nsimap timeout 1800]
        set us [ns_config nsimap user ""]
        if { $ssl_p } {
            set fl "/ssl"
        } else {
            set fl ""
        }
    }

    if { !$exists_p || $changes_p } {
        set validated_p 1
        set n_pv_list [array names new]
        if { $changes_p } {
            # new = n
            foreach n $n_pv_list {
                switch -exact -- $n {
                    port -
                    timeout {
                        if { $n_arr(${n}) eq "" } {
                            set v_p 1
                        } else {
                            set v_p [string is digit -strict $n_arr(${n})]
                            if { $v_p } {
                                if { $n_arr(${n}) < 0 } {
                                    set v_p 0
                                }
                            }
                        }
                    }
                    name_mb -
                    flags -
                    host -
                    password -
                    user {
                        if { $n_arr(${n}) eq "" } {
                            set v_p 1
                        } else {
                            set v_p [regexp -- {^[[:graph:]\ ]+$} $n_arr(${n})]
                            if { $v_p
                                 && [string match {*[\[;]*} $n_arr(${n}) ]
                             } {
                                set v_p 0
                            }
                        }
                    }
                    defaults {
                        ns_log Warning "acs_mail_lite::imap_conn_set  No validation check made for parameter '${n}'"
                    }
                }
                if { !$v_p } {
                    set validated_p 0
                    ns_log Warning "acs_mail_lite::imap_conn_set  value '$n_arr(${n})' for parameter '${n}' not allowed."
                }
            }
        }

        if { $validated_p } {
            foreach ic_n $n_pv_list {
                set ${ic_n} $n_arr($ic_n)
            }

            db_transaction {
                if { $changes_p } {
                    db_dml acs_mail_lite_imap_conn_d {
                        delete from acs_mail_lite_imap_conn
                    }
                }
                db_dml acs_mail_lite_imap_conn_i {
                    insert into acs_mail_lite_imap_conn
                    (ho,pa,po,ti,us,na,fl)
                    values (:ho,:pa,:po,:ti,:us,:na,:fl)
                }
            }
        }
    }
    set i_list [list ]
    foreach i $ic_list {
        set svi [string range $i 0 1]
        set sv [set ${svi}]
        lappend i_list ${i} $sv
    }
    return $i_list
XQL Not present:
Generic, PostgreSQL, Oracle
[ hide source ] | [ make this the default ]
Show another procedure: