2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 // WARNING! this doesn't perform any sanity checks on "accounts.rc"!
18 module zsq_create_accounts
is aliced
;
29 // ////////////////////////////////////////////////////////////////////////// //
30 void setMonthLimits () {
31 auto st
= dbConf
.persistentStatement(`
36 DO UPDATE SET value=:value
40 .bindConstText(":name", "/mainpane/msgview/monthlimit")
45 .bindConstText(":name", "/mainpane/msgview/monthlimit/accounts")
50 .bindConstText(":name", "/mainpane/msgview/monthlimit/dmars_ng")
55 .bindConstText(":name", "/mainpane/msgview/monthlimit/lj_and_ljr")
61 // ////////////////////////////////////////////////////////////////////////// //
62 void main (string
[] args
) {
63 ChiroTimerEnabled
= true;
64 chiroParseCommonCLIArgs(args
);
66 // here, i don't have any threads at all
67 if (sqlite3_config(SQLITE_CONFIG_SINGLETHREAD
) != SQLITE_OK
) throw new Exception("cannot switch SQLite to multi-threaded mode");
70 foreach (string s
; args
[1..$]) {
71 if (s
== "force") allowed
= true;
73 if (!allowed
) throw new Exception("use \"force\" to rebuild");
78 chiroRecreateConfDB();
81 auto stInsAcc
= dbConf
.persistentStatement(`
83 ( checktime, nosendauth, debuglog, name, recvserver, sendserver, user, pass, realname, email, inbox, nntpgroup)
84 VALUES(:checktime,:nosendauth,:debuglog,:name,:recvserver,:sendserver,:user,:pass,:realname,:email,:inbox,:nntpgroup)
87 dbConf
.execute("BEGIN TRANSACTION;");
88 scope(failure
) dbConf
.execute("ROLLBACK TRANSACTION;");
90 foreach (string
[] argv
; loadRCFile("accounts.rc")) {
91 string accname
= argv
[1];
92 if (!isValidUTFNick(accname
)) throw new Exception("invalid account name \""~accname
~"\"");
93 string inbox
= "/accounts/"~accname
~"/inbox";
96 .bind(":checktime", 15)
97 .bind(":nosendauth", 0)
99 .bindConstText(":name", accname
)
100 .bindConstText(":recvserver", "")
101 .bindConstText(":sendserver", "")
102 .bindConstText(":user", "")
103 .bindConstText(":pass", "")
104 .bindConstText(":realname", "")
105 .bindConstText(":email", "")
106 .bindConstText(":inbox", inbox
)
107 .bindConstText(":nntpgroup", "");
109 for (usize aidx
= 2; aidx
< argv
.length
; ) {
110 string aname
= argv
[aidx
++];
112 case "debuglog": case "debug_log":
113 stInsAcc
.bind(":debuglog", 1);
115 case "no_debuglog": case "no_debug_log":
116 stInsAcc
.bind(":debuglog", 0);
118 case "smtp_no_auth": case "smtp_noauth":
119 stInsAcc
.bind(":nosendauth", 1);
124 stInsAcc
.bindConstText(":user", argv
[aidx
++]);
128 stInsAcc
.bindConstText(":pass", argv
[aidx
++]);
133 stInsAcc
.bindConstText(":realname", argv
[aidx
++]);
136 stInsAcc
.bindConstText(":recvserver", argv
[aidx
++]);
140 stInsAcc
.bindConstText(":sendserver", argv
[aidx
++]);
145 stInsAcc
.bindConstText(":email", argv
[aidx
++]);
149 string s
= argv
[aidx
++];
150 while (s
.length
&& s
[0] == '/') s
= s
[1..$];
151 while (s
.length
&& s
[$-1] == '/') s
= s
[0..$-1];
154 stInsAcc
.bindText(":inbox", s
);
158 stInsAcc
.bindConstText(":nntpgroup", argv
[aidx
++]);
163 import std
.conv
: to
;
164 stInsAcc
.bind(":checktime", argv
[aidx
++].to
!uint);
168 throw new Exception("unknown option \""~aname
~"\"");
177 throw new Exception("unknown account type \""~argv
[0]~"\"");
184 dbConf
.execute("COMMIT TRANSACTION;");
186 writeln(count
, " accounts added.");
188 writeln("closing the db");