kolabadmin/0000755000175000017500000000000010757564647012530 5ustar tobiastobiaskolabadmin/pics/0000755000175000017500000000000010757564623013460 5ustar tobiastobiaskolabadmin/pics/user.png0000644000175000017500000000651410757564557015160 0ustar tobiastobiasPNG  IHDR00WgAMA7 IDATxkp]U{o]Id9d+~4nĉ3$ |B[f$30С 3@ e-O:L3iӤiZ'ih vb˱,)<Ň}jDR3=k_)͡{ GCydC/̈́xHBբފLi3uk+̼X&ݾ`R';1ѐ M ^L<(&jqc<hԂ@wǙc/3OXvp:s.\ҝ(fBO1Pd:jr# "Ay,4@ 409Ozg孡ƫӥ?:z}x)0MpShJ 5~KO}KH$W6qRK63{ۦJ@5A*W'?Ml_+< Vo4&Vg5 MɣϜ1{-}$ + > d5d du(ޜ7|?^|G䱿Nӽ{5\8vQ6qU!k9 d xТ!yx:){ ON`&J'7娋/9}ʥc3_>{O`|۷ȶ"wQ 5[FBf 4PxF%@P,uLl( ZJĩ֩ȒFk=\zO=-ꆛnD=Q)o_[!Bdyl(%d\5ykʲ$eow޾gcT+RY!!W߷M붗b(q$Ϡb:5Q'ܾ9$s Š;@Z.KHwKu^C6rC;Ǐ=q8ϾR^ywrh .T W.liGV{\H9sm 2jL|8]FvidB`(vLgsѮiBk?4YE:T4mwX dG?|\e{L Kv5_u,_w؅Ѯw{TU"i7"VVJ3B[m\Zҋ"{" [0Fw`QI:J:2Uo\-o-:T$4>ۍ zB((smQ+Ř,BLy'\E5:5{ Yz3jꁶ䛟Ճڡt2gE`+-%ٖ(95C7tiZV;%$d¤Raˢt3$llKQ+# uBH>4QBۜڳܞᙫ)sNVLɒiP1ZvUF !ւZtMY\zM@qXMb]?!ŒX0ZxP5rSiE:S'i^b2}|%`חPQb{KڭB_QXi]hkJS+vqi?.ĕƅNMn{-)f<hMWd=EбvD!Xb^|Es$k0S\dP˧e@kzq8fU&\lh(f 9E_7P0P 9y%6?݉4\C3Q5\x:9cKOz_QlC`jMGu΃}kM캾-yJ޼CDV@=YxsJXo1yzᇎTxxT4o{6[ڞ7ӝ 1h1ZƊ^*ofN^8UUg.W&^?;uԫ6^V (qMt ^tE X+uf NӸ*qvJLOhIENDB`kolabadmin/pics/administrator.png0000644000175000017500000000573710757564557017070 0ustar tobiastobiasPNG  IHDR00WbKGD pHYs  tIME Yg lIDAThŚk\gy3 z7{ƉݒҲm(A D|RԊV *DD%@%$B( 4!\[zm{O?gvH̜ٙ>y,G<0|rX_,_S^:Zh//rjn煵!'e1>{? |m4'*z/]| >g7{=ދ%}^Ȫd?ss/]!t:N877(!HYZ%YN#>:wB?~ gƃYy!I{Wu7RL8aimB,/[Wx= $YF5M/G_rf!p%N%`q:yʳmTsq7;56j5u\V8A@J^G4F\Ak,m(1bIP4$)Jϋ"CA@ZEQD9k޸( aЮaF!^HV;<|%<iZ-d(p͆S(%4<+Ie!IT0L)gXq.)Bz-Ez(MCVȱ0DJ`Iziе$ |E4È}oW B @hZdj(0 dEAѴuU(yB;:Xh: svM2i" YM)gY(x+++M~)rN]g]H:f2Br(U5P,d!,k]./3 N= _UMW]dRS4 aȪ8itw-@ՃC($''|IahZ.Ps9iD&GQ(}?*an| O@3l ݄V^-[fB5E4Zd,4VK#+ yqp3w4>Q.,j>^*!Y@1V(GUJh-,G ؏3W>QAR \FTzri4:EY~o_ +h\m_w]8r0@e.rh(V, lYUĖ$ۦ~ g{~a#,Quj0 mΟ=KqfgqS*Iqº4Nf8=|,2XG$"w M#W*1 o) @wNHtd!++˵5нi7dK[vKM~8QѴ4q+ﺽR]g 3W xd4 |?R`vY"]_7^!:} a4;W @Ÿ_;9yi[tw+W'kwj{@ydr1q!*6A_$ع&́t&i%EVK7C} oW≵idJ%Fa}aj'hgmr1D n1d!R kW=xjZ); lPUR NC'H:`hWumO(i!tbP;X.FjoZ ʈLɤwe@*}ˊ@) ^΋ꕈU<ۦlv.Ẁ33MLR行˥'Ir!$vidxr\NcP}e++<]"mn}z.jEM v;Lkn Ǐr'DfW@nQxGީ)o1DdY"0jN ZXh/,8wcǂ'_xa!8 ׫[dx z3##6Fd`r0zΌ}k EDcz'i..2w/<'OJtHV` 70pwHYГ9 ZFQO@kP*u$ӹ+:#N"0@є Hb@#@ׁ$CIENDB`kolabadmin/pics/addressbook.png0000644000175000017500000001070310757564557016475 0ustar tobiastobiasPNG  IHDR00WgAMA7tEXtSoftwareAdobe ImageReadyqe<UIDATxb?P0@ yА@ yА@FFF VagPVvf!?9?޼9sHr Ë~*A89xxde-xyPf`ff_b v@[0i r)(2H0ܻk.ÇG@D{A\\ʲ 22f@3q301/ 76=311s𫫋2hj1hi3() 1 r߸b||r߹PFQQuprd8/\pX` ߘM  GkkK03$aP?``q ~usfZ@p3pq Cל_,! 4/|I@5g L@9''8Yh))^]x'0PAQuc@Gq@BT?@CP:bccQfRV80@88XqWW3QE`1?0*Ƨ' 44Iҿ`i`:66dWPa;so޼7`򇁝Xڈ%05r({wa'6\o>| _| L. B }@̃@5|A7 310T&FXe<1q`C8P>zɓW _`a,8A扁2+0oC/<^cǔ]{ *0מED$%Q3/.ÿ_Xx8Yr^p+8Aɀ œ BB`ʊiAA^ Mu HNM7~x{ׯś*8eeor5 ?c`e`b[2*3j8?7!$$Z 1P)r04?۷& np2zVSU|۷*ff >>pB^31(ů_Ԁx6`Q!k { `m/  K@70|}W'fB؄Pexz} `Ph;`x/_C#0٠yC@dff&]F`f8p@Q]߿( p;A5H?8= B0J6uk#0>} OfxR ""Ġc"Hl<dc6Id $0y_KHC)O9'Bжj߿}gػ0oY P!p6?X Ҡ$WXR%#))vGjf@@jw/lmld!?a.&;#301bTKI2HKkdq  J^~33 ~p̜ ׮10DiV R+m?|,I`sc`)>zp536ܴ|xa`n % XC I߿&o }: @ 5GAToݲ|Y@H`>-9Y 3|xA@J s2[J Obxx `t"  t'b>o|;/@r 8nnp78 ;`1,߿ b+Wވ C ASʔ=0#3. $`jp~ > Zm ?1x[fmo L ~7%^|iP P2egg7%@TBxP +zYXXɉؼjpެ ~E- >uko9pԸ2PFTfXu')~Ef-+v3| =KՑ!E/[CY6fG{Ze\QQ^p *@.H_V+C+P1 99.vKA. Xp @`|@q͛_ 䳃:a O+xY0;0c`Vy>=5 |Ύ0}- N_Ġ)̰6uI Q`JBfV8/824ȳ|Ԫ@ZBIT߿W` ]ݹID h '$m2gQ| ! /nbt Jz >204#0CJ2H0xHY&h-q4lXxP- > xRТX#>7oP @,v._+Wު36dp501pr d`3ypu+Vn wa?N deb AM P%5HYP>al)I`|3 x |AKޫ| Q7_3pp1<je^s+ z "<6 +?ggdxX|b\܉2$VVjhPI '@SVVF`cy`CBve@ p3Vy_@Oh nfE!+:Uz3Îgm&Hۇg`P Av<+nA_K-P8opN @Bw߼ 7K?I/ }aA#C]vnzt,? Xbw78YB08:<0Mgy^2 s Lv:Yp۷?o,V:)Obw_HA;e_ B80=ÿ:(\ h)^Ki`lf˗?8wp(`çϿ!?]鞿 L?=e_ Ozl> IǏ҇@럃R1ЀMyp {ow`1\beXew~C%3ރ ~t+R Xyx0{;G`P:Fd<`tw,^2C{ZMpzT0׀˗(jjr0wA,,{@?@Lƣ& FpK:~Ș$M1 D3;;g(+? x>|x gۤf?wyw?;b8 WRz}z'nolHN|?ވnIˠH.;R1m;;C8.9^H29Hk o&F&\2w}3OWGgϾ>222>M)."済p' 7( n[H<^$TL@[UuwɁuh |%؅;oO'fXZZ,\pWA{A%1`-13aqpob.T|-ܡr!SVMz.2NSN~+_8:=L*(+7+PKހ+aPs,s#hRw)q+|/b> JUJ!Jwd n*KN*۵㟮ezR-W1QE +,o kI;nk.f&o4嵟a>IR:1uKW;vkL5Nl IAJb KTErKeګBܸ[ƚ tr`<8lXQ$F'5y˂fecF^#9uw>ŠpwqWK]b?##P'mbiSzusG{)K\rUeTU[-ʹj,us<7=B3;3zMDOМ o{WyC80I,//\Yopw-WL*06(dQqw:{K9WWF蕁T9UAJ6}щw&0:¸K[jZX6ԇAD#BuBSӇnPgOr7&_IzEhA:E){7@P<}cvj&?v~ۿg_W۷MD w|'߱ёraނVJTd;cTUܵo͉؅k_}V^Qd4_ͷv!DS5Rόȋ/hϟ׭;6հ7'um~ÒFu/SO9rľoh@0_ 22l"YbTz=,J @駟98qZ,1 ?_%9@@4 ܝ, ܭN?zݙ@T< .WV]1+HRNAWݙN֙HY@LUe>۸K;!ݶյ 1S3q vNo~͟iUn!q͂x5b< <^.]!s?{Kk n[q"dQ~.-CO7nB*EeW6SdA>b^].vNRVzװ]*ȂxE'# ?Lސ+U k]h޶fEVȶ:] ݁V_༼L`dxD-^!IVHdYɂX#L͞-=o3\uTw 6eIu]A10 \}[zWv*n*0~_g{.*<MXPUa\kkw.ҍa`Ԏç>or15*Rq2%R 1s,p̷yll'&V.pȂP'S!]xD`}cEY]]1:Y&Ј+~+<>՟|jkߧB(g}ʝ BOIv^~5H=!dK j\j˔׳N ^A$W>sADEE =~J~ 204fuX记ݨQ,1eܾubuvvUe 6>_;`eSGeVsBJPtqi۷nY2ӵ5RnY׀T({("dYmY1u[_@d+eݶS2??oH bs$"7nsT"YB$,r\c &,f.--"̒$?X1;toW98ZK Cb>NE:̂%Asa`ybbǷi ȯs+^Ǟ'{j]Ǒ#G03$PωR!3{m j *hP3~Sl  J:ovቻ+]^Wh6Pw.8?TѣG)˂:Q)j;uAH j*y) ةȟوv,S I贴4[<ד"k3mV=>b/~_l MbfUĖSC~{3/a:C۟#ϐ`~ 㫉l.bFS<䴙6-F,5_|q:oVkVf/jz۶oiUw/v -t`k\$7(*i#sT@w١c!(=J{hg+AwgSdZms7C<_ӓIV{/"f͜2huh5pDDdl:es[=w=g1)sȥ+WlixV%̮.dסG kog NȁG|r!]\~qtW/ga!֕EQga}BwSSO=uKF̿?26t\<A.~ֶ ynϋϾA.M%*E;GK᷀-?G==596je[rصyrW$f疺W_q嗀sIiu2S jX%un孷;ԯ| d/y7o~{ a:aIENDB`kolabadmin/pics/sharedfolder.png0000644000175000017500000000725010757564557016642 0ustar tobiastobiasPNG  IHDR00W pHYs  gAMA|Q cHRMz%u0`:o_FIDATxbd@ [?Sÿ qcxmׁR??1f@8\6Nl(gY ߁N>uN|Ę@,v\[gi3{AZU D?ob y@!#|-YP5\L6>~Fv!- ف ~Am~Y/6b h 'H se*0J3lp8 nHUyi'oyO/A?"6SˣKLz* Qc`rÏ?y^@CPTyG/˟Z?.01g.[Cڿ_J ^V= ^nL Fg54 ӭ4x$|,#/ @~s_>bX|@,T/r=b8h;#?6N9rr$]9"`Iai"Ƌ-f`ʑpdRd;2|2HAFL!w?c`8oFL/ӿ/<@(p^ yYLyԘ~A eP*fDG^[M={``k 'ˣG?|g+abз)`dF#}}F ؄\Ns|o-^| 6P Lg`E*{`J| ?w\Ǡ'Up6#CL_@s؁1\C?7P~c`L 336 y9Yuz1 G|*x_1|)Xj#+` 9Q.;pο 9D9 V$V; f7g6ReXv`rqxby bRa{ a~U`h #G `I1<{M ?P0V 7io` v\8l@%~}?4w?L8~?d~A T e!lb^ _0~``u$W`Y`£ʶ @Lg۽ni֛ys'6`?͒Sa3FF<ؖ ?"I7CK#0 (96 @ _ɔg?}0/Oefet~J/`4TG1d3011 "F*=OO7Қ$uC^ĐoǠ!|%#0CH!  R߀ٿ}z=sib+'1H20\_0 j:H@N>Ɵ%`З v0r_lc?ߐ@ ߻.-rd#n`H6e,^}^0?y1?j?n̰/`yy׽y@,pرlnSPp P7m~rAx;5^e0bcxπYm %$b!8A8PXȡr ~(Höx7K㯰fQ`ؒ(C?(!_~g.#=9ԑ@{u]DA~ - AbP XxgpPΤi M 0>N:2 bRqLȏz@<=.K-hF& nN-@@>cO7Ёi>_~߳3%fbMub <-&Ae/-XsH\Dfc_}ul֜זR\!}];ֿ$ԿmڥLTje#"e#3Tqy1~pFI C  R<Nj _8e_>a7 OtoaH77Cla:Y9\=1@gPa  @g>C__i\b AVHd0ô9IENDB`kolabadmin/pics/maintainer.png0000644000175000017500000000645610757564557016336 0ustar tobiastobiasPNG  IHDR00WbKGD pHYs  tIME @ IDAThŚ{y]3Y|).IK Q"5JAhVUU(T*UժiV*BQ4).8!8i0Ę{o廜?η^׬HG;;9}Ίzm[;#{_ՋyK_hkw `X@>+nT&8Ti}I<#L:</⳵"o}Bx%laM"HQN|Çͷʙshnxt]~2~LXkJqhSxkUD3! ;[~cNhw'kѪ46hWS]F !RiPH5)$ȴI<ⴀhFDI38s^-^ku8ivW6p͎\`5_|ap8Fy9_D_^X T~QRw_$V y4:kj0t\ۇ)BeGQ^^#k BjwwUl7Ϝ_pAZc4iiXn*utnͼGeT8y *t`RԀ%p7tWϪLLBtdۖTPqHιXzs/HzZSo?y|O2Y_QNqg[W╶BQ~ !udT:D{:8O<,_:WpHW۱g&Vk۟Fy7•qhSz rtEf Kzó eOGn xw1uIrL!bJh:$HͼGi]CGx?|F+VJ,6~i0!L<Aa[q}I# +L%7 GUAT{1_n<+WBrc1#72vdqxIo/`MRdXϏ xyԤ"&DHHێ3*~Tfpzj]_`. [Is5&1It1H:.M:I#:eNPs\8ٮZs ]Sm||7y+uX! 6tW>}EM 4֤QAu҃[w`xѪYKZ֐ۃf^KiV^OE6<_n8f=[3+VۉmH,ZJya&Ƙ4&}4]|Xl~ٯ++>' |mi#aO=k0vOkĮRj!\%:2hiM7L񍻐$rEME]րM]8ҍAim Ƭ ^A6H2^]]ShXOΞ|iAJ$*$1"$RBJ }WCHoP !B`rpfE$x$EN4tjG 0iT`+ߵrR™6BzXCa2[,u!q\ؼjZ `TuJ8K]gM粑78vBHK}:sd;+H5`ݪ5` /qw٠%f[H嗁k֏2O_*0 T2PoSw3㶕9y`.,Zm p8IENDB`kolabadmin/pics/kolab_logo.png0000644000175000017500000000363010757564557016306 0ustar tobiastobiasPNG  IHDR+UqIbKGD pHYs  d_8IDATx\m*%wuFtLfL:&4:/{s9A- . 6nԐiq~h@.NEmC uBܨh{\Z>a cp#dkJmD~F,"?K4Ӳ~Dއ,d 0"WcL!0<cݺ6k}pD[CM&6q]k·1>;+!3朗F[n61> ʤ垭|*: #Ep"`M,$oX9j@}  Q.p!|.?m½T$#/UC1a $Z>gdK<8y 븢N"+HذȺ#F>8w_qÖ߃TTHW}0ƜFx=G6G)0»KR yGd{,bGQ"j:&MDjLQG! Hǣ*Sbr K\'"$UAz2@ҪUsMpBxiDY Tܘ Xupiu8q& LThW&a(@'FWgjTrKٍBVimn~K]=ЀLc!P/^MzHˣ4/ƨFޔd5EcRleb":76Sm ʱ9@>'U, ;N 4QIf1 MtNP BS b.>T6SSEe}|WL9΂g:i#5ˋ¸Zڕ*p0ϱ:^ -= jc{h }tEY}fcvDEUοꢟIt_,|}FE(XԸDrLu:ZkC~٠Fo ]x*C?^O=nZ瑬۽x.I<}zY{€3uJB@k;lC6'U}C:s_NwލZt Iq}Bq%jU6op07L]n5=m+蝩 at%H% fdsZw?x@6mم0gNXB 'L5͈]wL@.z_E0Q6ofКMڻv@fЂ@{ /_9U~:G!҄w?MQq]! 1j }vqrWu8^M8h6Q1Vn{}(O*? ;KV#e#jGg @o :W>]cE|%{3tH<>[>^M?=>]qÕ_VO:]+גkg%˧]uƈo2_e\zܺ,@{/HP ukދ"Vzawx.B?eOk…?ή.DIENDB`kolabadmin/pics/distributionlist.png0000644000175000017500000001006710757564557017613 0ustar tobiastobiasPNG  IHDR00WgAMA7IDATxyeU}?g_0̰ ("fd05VYr#TEhUJ)MReRU1e$ IDPP D%2[Lݳ{{ ޮSu[~s~{% ې Z*4|L7M\{ܮqvK8Ա ,rߘ?9?Fl{z[?uKE?yo{֟~5|Ⱦۿ'p ޾w^ 4Z\:!@D:ls;6~rϡxPo]t׏]1Ub@9.df,[vmͨ|sSS1gF/.㛮a'yԚ{d'00)BB,+ Ou`X׋*1\y'DՃ L[Q/0{~] mAIL,$'8ׂRՕ\]G^vӟANO:ZYJu.qScWC$<ooυ\|͒BQ^-"$ BҞY_}{ۻ=Ha@KݴÌ<~sk6s0"JT  @Y&p$Ũe{@"IKF y<>E{^ccdrR/9pg:o_|9fa BS%@HP@ŧ^GBB Bǎ|; xٱ#yP-.e$D$Ғ@ hd#Hb:0O8t Z$M:hx<5ʶΆAqOU@LG 6Nn*oz P=wٲ{;LBAEĒ$v$YǤPKIS#4g1ID# U/I[TC(x3i{ QgRZ7ƭD J2$)2$ %a ufJ djHS-^qz;zR+]+-kDͮU[d{n]3'K]7صos_H!P $Q DIEr2Sca`uDӗh2M_Wݖj.bߠ,SrYuYYrZzM{vný`h9&t %j`~.áч[? 4\&%i%;ANR4|$-ѰuFW?~RN*gϞ>ڪd^e˺p?=| +)*jAN B%^0U8stqbĈ Fi"M0p44hQĮBWh [f4]:)CQ3`?y񷞟2wG%t&lQ}|//޷/2$clγLŔ뎩Y3c-;Ugzi9ے4&vm1B^aZZ//5+Z6xq|-;xٍq-=ܰ޶k`l83363] CWٶ>bp}k̏ r:\REl\}gqşxy=;6?]sElqAX ]zBu uwtBb'4I>'*w3{|+%rHk_V,=`#SO^={3uGFhӲдq4 44# P07VY}ղ,KҼ^v::=Os8jV+qɥ/[W`MЈ=N>)Tbu3SiCc}RMt$6G;{+fG Dh)y`U2P:OogcN ;&R JqHЬ2^w> ǥye<#?g ݞЊ]$ ve|ҥԵ {̢3z ?پl$xƧiP_2y[qp6mlynK-FmH\GdMA(s-m~`#Ғ0H H%"BSiHƃpilHb9X<0t<Xl+TB撚u.?~SGOo= D)T ѨʹSGN+33玏MyQ9!_k @H!HsHӬ+E`5^f4zՂ/ڰWIENDB`kolabadmin/service_record.cpp0000644000175000017500000001163410757564565016236 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "tool.h" #include "service_record.h" using namespace Form; Entry ServiceRecord::loadEntry( const QString&, PagePolicy::State state ) { if ( state != PagePolicy::Modify ) return Entry(); Entry entry = Entry::fromLdapEntry( Tool::kolabSettings( Connection::self() ) ); return entry; } bool ServiceRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state != PagePolicy::Modify ) return false; // distribution lists if ( !entry.value( "distributionlists" ).isEmpty() ) { QString dn = Tool::dnForMailOrAlias( Connection::self(), entry.value( "distributionlists" ) ); if ( dn.isEmpty() ) { errorMsg = QObject::tr( "You have to enter a valid email address of this system!" ); return false; } QLdapEntry kolabSettings = Tool::kolabSettings( Connection::self() ); QStringList distributionLists; distributionLists.append( "hostmaster" ); distributionLists.append( "postmaster" ); distributionLists.append( "abuse" ); distributionLists.append( "virusalert" ); distributionLists.append( "MAILER-DAEMON" ); for ( int i = 0; i < distributionLists.count(); ++i ) { QLdapEntry entry; entry.addValue( "objectClass", "top" ); entry.addValue( "objectClass", "kolabGroupOfNames" ); entry.addValue( "cn", distributionLists[ i ] ); entry.addValue( "mail", QString( "%1@%2" ).arg( distributionLists[ i ], kolabSettings.value( "postfix-mydomain" ) ) ); entry.addValue( "member", dn ); QString dn = QString( "cn=%1,%2" ).arg( distributionLists[ i ], Connection::self()->baseDn() ); if ( !Connection::self()->add( dn, entry ) ) { errorMsg += QString( "Could not create distribution list '%1': %2" ) .arg( entry.value( "cn" ), Connection::self()->errorString() ); } } } QLdapEntry ldapEntry; /** * Services */ ldapEntry.setValue( "cyrus-pop3", entry.value( "cyrus-pop3" ) ); ldapEntry.setValue( "cyrus-pop3s", entry.value( "cyrus-pop3s" ) ); ldapEntry.setValue( "cyrus-imap", entry.value( "cyrus-imap" ) ); ldapEntry.setValue( "cyrus-imaps", entry.value( "cyrus-imaps" ) ); ldapEntry.setValue( "cyrus-sieve", entry.value( "cyrus-sieve" ) ); ldapEntry.setValue( "proftpd-ftp", entry.value( "proftpd-ftp" ) ); ldapEntry.setValue( "apache-http", entry.value( "apache-http" ) ); ldapEntry.setValue( "postfix-enable-virus-scan", entry.value( "postfix-enable-virus-scan" ) ); /** * Quota */ ldapEntry.setValue( "cyrus-quotawarn", entry.value( "cyrus-quotawarn" ) ); /** * Free/Busy */ ldapEntry.setValue( "kolabFreeBusyPast", entry.value( "kolabFreeBusyPast" ) ); ldapEntry.setValue( "apache-allow-unauthenticated-fb", entry.value( "apache-allow-unauthenticated-fb" ) ); /** * Networks */ const QStringList networks = entry.values( "postfix-mynetworks" ); for ( int i = 0; i < networks.count(); ++i ) ldapEntry.addValue( "postfix-mynetworks", networks[ i ] ); /** * Smtp */ ldapEntry.setValue( "postfix-relayhost", entry.value( "postfix-relayhost" ) ); ldapEntry.setValue( "postfix-relayport", entry.value( "postfix-relayport" ) ); /** * Mail */ ldapEntry.setValue( "postfix-allow-unauthenticated", entry.value( "postfix-allow-unauthenticated" ) ); /** * Mail filter */ ldapEntry.setValue( "kolabfilter-verify-from-header", entry.value( "kolabfilter-verify-from-header" ) ); ldapEntry.setValue( "kolabfilter-allow-sender-header", entry.value( "kolabfilter-allow-sender-header" ) ); ldapEntry.setValue( "kolabfilter-reject-forged-from-header", entry.value( "kolabfilter-reject-forged-from-header" ) ); /** * Hosts */ const QStringList hosts = entry.values( "kolabHost" ); for ( int i = 0; i < hosts.count(); ++i ) ldapEntry.addValue( "kolabHost", hosts[ i ] ); /** * Modify the data in ldap. */ QString dn = QString( "k=kolab,%1" ).arg( Connection::self()->baseDn() ); if ( !Connection::self()->modifyAttributes( dn, ldapEntry ) ) { errorMsg = Connection::self()->errorString(); return false; } return true; } kolabadmin/connection.cpp0000644000175000017500000000223010757564565015367 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" Connection* Connection::mSelf = 0; Connection::Connection() { } Connection::~Connection() { } void Connection::setName( const QString &name ) { mName = name; } QString Connection::name() const { return mName; } Connection* Connection::self() { if ( !mSelf ) mSelf = new Connection; return mSelf; } kolabadmin/administrator_listingmodel.h0000644000175000017500000000267210757564565020341 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADMINISTRATOR_LISTINGMODEL_H #define ADMINISTRATOR_LISTINGMODEL_H #include "listingmodel.h" class AdministratorListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/integerfield.cpp0000644000175000017500000000313410757564565015675 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "integerfield.h" using namespace Form; IntegerField::IntegerField( const QString &name, QWidget *parent ) : Field( name, parent ) { mSpinBox = new QSpinBox( this ); fieldLayout()->addWidget( mSpinBox, 0, 0 ); } void IntegerField::loadEntry( const Entry &entry ) { if ( !defaultValue().isEmpty() ) mSpinBox->setValue( defaultValue().toInt() ); if ( !entry.value( name() ).isEmpty() ) mSpinBox->setValue( entry.value( name() ).toInt() ); } void IntegerField::saveEntry( Entry &entry ) const { entry.setValue( name(), QString::number( mSpinBox->value() ) ); } bool IntegerField::isValid( QString&, PagePolicy::State ) const { return true; } void IntegerField::setEditable( bool editable ) { mSpinBox->setEnabled( editable ); } kolabadmin/service_page.h0000644000175000017500000000266710757564565015347 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SERVICE_PAGE_H #define SERVICE_PAGE_H #include "page.h" class ServicePage : public Page { public: ServicePage(); ~ServicePage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual bool hasListingMode() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: Form::Description *mDescription; Form::PagePolicy *mPolicy; Form::Record *mRecord; }; #endif kolabadmin/dialog.h0000644000175000017500000000236710757564565014147 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DIALOG_H #define FORM_DIALOG_H #include #include "container.h" #include "page.h" namespace Form { class Dialog : public QDialog { Q_OBJECT public: Dialog( Page *page, const QString &id, PagePolicy::State state, QWidget *parent ); public Q_SLOTS: virtual void accept(); private: Page *mPage; QString mId; PagePolicy::State mState; Container *mContainer; }; } #endif kolabadmin/entry.h0000644000175000017500000000306410757564565014044 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ENTRY_H #define FORM_ENTRY_H #include #include #include "qldap.h" namespace Form { class Entry { public: typedef QList List; Entry(); ~Entry(); void setId( const QString &id ); QString id() const; QStringList keys() const; QString value( const QString &key ) const; QStringList values( const QString &key ) const; void setValue( const QString &key, const QString &value ); void addValue( const QString &key, const QString &value ); void clearValue( const QString &key ); void dump() const; static Entry fromLdapEntry( const QLdapEntry &ldapEntry ); private: QMap mValues; QString mId; }; } #endif kolabadmin/maintainer_listingmodel.h0000644000175000017500000000266110757564565017606 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINTAINER_LISTINGMODEL_H #define MAINTAINER_LISTINGMODEL_H #include "listingmodel.h" class MaintainerListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/qldap.h0000644000175000017500000001321110757564565013777 0ustar tobiastobias/* Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef QLDAP_H #define QLDAP_H #include #include #include class QLdapEntry; class QLdapResponse; class QLdap : public QObject { Q_OBJECT public: /** * The scope for LDAP searches * - Base Searches on the same level as the base DN * - OneLevel Searches one level below the base DN * - Sub Searches on the whole subtree of the base DN */ enum Scope { Base, OneLevel, Sub }; /** * Constructs a QLdap object. */ QLdap( QObject *parent = 0 ); /** * Constructs a QLdap object with a host name and port number associated. */ QLdap( const QString &host, quint16 port = 389, QObject *parent = 0 ); /** * Destroys the QLdap object. */ virtual ~QLdap(); /** * Sets the host name. */ void setHost( const QString &hostName ); /** * Returns the host name. */ QString host() const; /** * Sets the port number. */ void setPort( int port ); /** * Returns the port number. */ int port() const; /** * Sets the user name. */ void setUser( const QString &user ); /** * Returns the user name. */ QString user() const; /** * Sets the password. */ void setPassword( const QString &password ); /** * Returns the password. */ QString password() const; /** * Sets the base DN */ void setBaseDn( const QString &baseDn ); /** * Returns the base DN. */ QString baseDn() const; /** * Searches for all entries with base DN @param base in the @param scope, which * match the given @param filter. * If @param attributes is not empty, only the contained attributes are returned. * @param sortBy is the name of the field which is used for sorting the return. * * @return A QLdapResponse filled with the matching entries on success, an invalid * QLdapResponse otherwise. */ QLdapResponse search( const QString &base, Scope scope, const QString &filter, const QStringList &attributes = QStringList(), const QString &sortBy = QString() ); /** * Adds the @param entry under the given @param dn to the LDAP directory. * * @return true on success, false otherwise. */ bool add( const QString &dn, const QLdapEntry &entry ); /** * Adds the set attributes of @param entry to the LDAP entry with the * given @param dn. * * @return true on success, false otherwise. */ bool addAttributes( const QString &dn, const QLdapEntry &entry ); /** * Modifies the set attributes of @param entry in the LDAP entry with the * given @param dn. * * @return true on success, false otherwise. */ bool modifyAttributes( const QString &dn, const QLdapEntry &entry ); /** * Removes the set attributes of @param entry in the LDAP entry with the * given @param dn. * * @return true on success, false otherwise. */ bool removeAttributes( const QString &dn, const QLdapEntry &entry ); /** * Removes the entry with the given @param dn from the LDAP directory. * * @return true in success, false otherwise. */ bool remove( const QString &dn ); /** * Renames the entry with the given @param dn to the entry with the * given @param newDn. * * @param baseDn The parent base dn. * @param deleteOld If true the @param dn is deleted automatically. */ bool rename( const QString &dn, const QString &newDn, const QString &baseDn, bool deleteOld ); /** * Returns the string presentation of the last occured error. */ QString errorString() const; private: bool change( const QString&, const QLdapEntry&, int ); bool connect(); bool bind(); bool unbind(); bool disconnect(); class Private; Private *d; }; class QLdapEntry { public: typedef QList List; QLdapEntry(); ~QLdapEntry(); QString dn() const; void setDn( const QString &dn ); QStringList attributeNames() const; QString value( const QString &attributeName ) const; QStringList values( const QString &attributeName ) const; void setValue( const QString &attributeName, const QString &value ); void addValue( const QString &attributeName, const QString &value ); void clearValue( const QString &attributeName ); void dump() const; private: QString mDn; QMap mValues; }; class QLdapResponse { public: QLdapResponse(); ~QLdapResponse(); bool isValid() const; QLdapEntry::List entries() const; void setEntries( const QLdapEntry::List &entries ); void dump() const; private: QLdapEntry::List mEntries; bool mValid; }; #endif kolabadmin/addressbook_description.h0000644000175000017500000000206310757564565017604 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADDRESSBOOK_DESCRIPTION_H #define FORM_ADDRESSBOOK_DESCRIPTION_H #include "description.h" namespace Form { class AddressBookDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/user_record.cpp0000644000175000017500000002644410757564565015561 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "auth.h" #include "connection.h" #include "connectioninfomanager.h" #include "crypto.h" #include "tool.h" #include "user_record.h" using namespace Form; Entry UserRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); QLdapEntry ldapEntry = response.entries().first(); Entry entry = Entry::fromLdapEntry( ldapEntry ); QStringList parts = id.split( "," ); if ( parts.contains( "cn=groups" ) ) entry.setValue( "accttype", "group" ); else if ( parts.contains( "cn=resources" ) ) entry.setValue( "accttype", "resource" ); else if ( parts.contains( "cn=internal" ) ) entry.setValue( "accttype", "internalUser" ); else entry.setValue( "accttype", "user" ); if ( entry.values( "kolabInvitationPolicy" ).isEmpty() ) entry.setValue( "kolabInvitationPolicy", "ACT_MANUAL" ); return entry; } bool UserRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QLdapEntry ldapEntry; ldapEntry.addValue( "objectClass", "top" ); ldapEntry.addValue( "objectClass", "inetOrgPerson" ); ldapEntry.addValue( "objectClass", "kolabInetOrgPerson" ); ldapEntry.setValue( "givenName", entry.value( "givenName" ) ); ldapEntry.setValue( "sn", entry.value( "sn" ) ); ldapEntry.setValue( "cn", entry.value( "givenName" ) + " " + entry.value( "sn" ) ); // handle password if ( !entry.value( "password" ).isEmpty() ) { QByteArray data = "{sha}" + Crypto::sha1( entry.value( "password" ).toUtf8() ).toBase64(); ldapEntry.setValue( "userPassword", QString::fromUtf8( data ) ); } else { ldapEntry.setValue( "userPassword", entry.value( "userPassword" ) ); } ldapEntry.setValue( "mail", entry.value( "mail" ).toLower() ); ldapEntry.setValue( "uid", entry.value( "uid" ).toLower() ); if ( state == PagePolicy::Add ) { if ( entry.value( "uid" ).isEmpty() ) ldapEntry.setValue( "uid", entry.value( "mail" ).toLower() ); } ldapEntry.setValue( "kolabHomeServer", entry.value( "kolabHomeServer" ) ); if ( !entry.value( "title" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "title", entry.value( "title" ) ); if ( !entry.value( "o" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "o", entry.value( "o" ) ); if ( !entry.value( "ou" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "ou", entry.value( "ou" ) ); if ( !entry.value( "roomNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "roomNumber", entry.value( "roomNumber" ) ); if ( !entry.value( "street" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "street", entry.value( "street" ) ); if ( !entry.value( "postOfficeBox" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "postOfficeBox", entry.value( "postOfficeBox" ) ); if ( !entry.value( "postalCode" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "postalCode", entry.value( "postalCode" ) ); if ( !entry.value( "l" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "l", entry.value( "l" ) ); if ( !entry.value( "c" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "c", entry.value( "c" ) ); if ( !entry.value( "telephoneNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "telephoneNumber", entry.value( "telephoneNumber" ) ); if ( !entry.value( "facsimileTelephoneNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "facsimileTelephoneNumber", entry.value( "facsimileTelephoneNumber" ) ); if ( !entry.value( "kolabFreeBusyFuture" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "kolabFreeBusyFuture", entry.value( "kolabFreeBusyFuture" ) ); const QStringList invitationPolicies = entry.values( "kolabInvitationPolicy" ); for ( int i = 0; i < invitationPolicies.count(); ++i ) ldapEntry.addValue( "kolabInvitationPolicy", invitationPolicies[ i ] ); const QStringList alias = entry.values( "alias" ); for ( int i = 0; i < alias.count(); ++i ) ldapEntry.addValue( "alias", alias[ i ] ); const QStringList delegates = entry.values( "kolabDelegate" ); for ( int i = 0; i < delegates.count(); ++i ) ldapEntry.addValue( "kolabDelegate", delegates[ i ] ); if ( !entry.value( "cyrus-userquota" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "cyrus-userquota", entry.value( "cyrus-userquota" ) ); QString dnPrefix; if ( entry.value( "accttype" ) == "user" ) dnPrefix = ""; else if ( entry.value( "accttype" ) == "internalUser" ) dnPrefix = "cn=internal,"; else if ( entry.value( "accttype" ) == "group" ) dnPrefix = "cn=groups,"; else if ( entry.value( "accttype" ) == "resource" ) dnPrefix = "cn=resources,"; QString domainDn = dnPrefix + Connection::self()->baseDn(); if ( state == PagePolicy::Modify ) { QString newDn; if ( !ldapEntry.value( "cn" ).isEmpty() ) newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), domainDn ); else newDn = entry.id(); /** * The 'cn' of the user has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { /** * Check for distribution lists with this user as member. */ QString filter = QString( "(&(objectClass=kolabGroupOfNames)(member=%1))" ).arg( entry.id() ); QLdapResponse response = Connection::self()->search( Connection::self()->baseDn(), QLdap::Sub, filter ); if ( !response.isValid() ) { errorMsg = Connection::self()->errorString(); return false; } /** * There is at least one matching distribution list... */ if ( !response.entries().isEmpty() ) { QStringList listNames; QLdapEntry::List entries = response.entries(); for ( int i = 0; i < entries.count(); ++i ) { listNames.append( entries[ i ].value( "cn" ) ); } errorMsg = QObject::tr( "Account could not be modified because the following distribution lists depend on it: " ) .arg( listNames.join( ", " ) ); return false; } /** * Now rename the old entry to the new one by using a temporary entry to * avoid data loose on race condition. */ QStringList dnParts = entry.id().split( "," ); QString randomString = QString::fromLocal8Bit( dnParts.first().toLocal8Bit().toBase64() ); randomString.replace( "=", "_" ); randomString.replace( ",", "_" ); dnParts.removeFirst(); // remove the 'cn=' entry QString tmpBaseDn = dnParts.join( "," ); QString tmpDn = QString( "cn=%1" ).arg( randomString ); if ( !Connection::self()->rename( entry.id(), tmpDn, tmpBaseDn, false ) ) { errorMsg = QObject::tr( "Could not rename %1 to %2: %3" ) .arg( entry.id(), tmpDn, Connection::self()->errorString() ); return false; } if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add %1 as %2: %3" ) .arg( entry.id(), newDn, Connection::self()->errorString() ); return false; } if ( !Connection::self()->remove( QString( "%1,%2" ).arg( tmpDn, tmpBaseDn ) ) ) { errorMsg = QObject::tr( "Could not remove old entry %1,%2: %3" ) .arg( tmpDn, tmpBaseDn, Connection::self()->errorString() ); return false; } } ldapEntry.setDn( newDn ); /** * Users are not allowed to modify some attributes, so * remove them here from the query. */ if ( Auth::self()->group() == Auth::Users ) { ldapEntry.clearValue( "sn" ); ldapEntry.clearValue( "cn" ); ldapEntry.clearValue( "mail" ); ldapEntry.clearValue( "uid" ); ldapEntry.clearValue( "kolabHomeServer" ); } if ( !Connection::self()->modifyAttributes( ldapEntry.dn(), ldapEntry ) ) { errorMsg = Connection::self()->errorString(); return false; } else { return true; } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), domainDn ); ldapEntry.setDn( dn ); if ( !Connection::self()->add( ldapEntry.dn(), ldapEntry ) ) { errorMsg = Connection::self()->errorString(); return false; } return true; } } else if ( state == PagePolicy::Delete ) { /** * Check for distribution lists with this user as member. */ QString filter = QString( "(&(objectClass=kolabGroupOfNames)(member=%1))" ).arg( entry.id() ); QLdapResponse response = Connection::self()->search( Connection::self()->baseDn(), QLdap::Sub, filter ); if ( !response.isValid() ) { errorMsg = Connection::self()->errorString(); return false; } QLdapEntry::List entries = response.entries(); for ( int i = 0; i < entries.count(); ++i ) { QLdapEntry distributionList = entries[ i ]; if ( distributionList.values( "member" ).count() == 1 ) { /** * The user is the only member of this group, so don't remove it. */ errorMsg = QObject::tr( "Account could not be deleted, distribution list '%1' depends on it" ) .arg( distributionList.value( "cn" ) ); return false; } else { /** * Remove the user from this distribution list. */ QLdapEntry deleteEntry; deleteEntry.setDn( distributionList.dn() ); deleteEntry.setValue( "member", entry.id() ); if ( !Connection::self()->removeAttributes( deleteEntry.dn(), deleteEntry ) ) { errorMsg = Connection::self()->errorString(); return false; } } } /** * Finally delete the user. */ QString ldapError; if ( !Tool::deleteObject( Connection::self(), entry.id(), ldapError ) ) { errorMsg = QObject::tr( "Could not delete user '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/user_page.h0000644000175000017500000000270210757564565014653 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef USER_PAGE_H #define USER_PAGE_H #include "page.h" class UserPage : public Page { public: UserPage(); ~UserPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual bool hasListingMode() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description *mDescription; Form::PagePolicy *mPolicy; Form::Record *mRecord; }; #endif kolabadmin/fieldfactory.h0000644000175000017500000000247010757564565015356 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_FIELDFACTORY_H #define FORM_FIELDFACTorY_H #include class QWidget; namespace Form { class Field; class FieldFactory { public: ~FieldFactory(); static FieldFactory *self(); /** * Returns a new field of the given type or 0 if the type is * unknown to the factory. */ Field *createField( const QString &type, const QString &name, QWidget *parent ) const; private: FieldFactory(); static FieldFactory *mSelf; }; } #endif kolabadmin/description.cpp0000644000175000017500000000432010757564565015555 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "description.h" using namespace Form; Description::Description() { } Description::~Description() { } Description::Entry::List Description::entries() const { return Entry::List(); } Description::Entry::Entry( Type type ) : mEntryType( type ) { } void Description::Entry::setName( const QString &name ) { mName = name; } QString Description::Entry::name() const { return mName; } void Description::Entry::setType( const QString &type ) { mType = type; } QString Description::Entry::type() const { return mType; } void Description::Entry::setValidator( const QString &validator ) { mValidator = validator; } QString Description::Entry::validator() const { return mValidator; } void Description::Entry::setLabel( const QString &label ) { mLabel = label; } QString Description::Entry::label() const { return mLabel; } void Description::Entry::setHeader( const QString &header ) { mHeader = header; } QString Description::Entry::header() const { return mHeader; } void Description::Entry::setComment( const QString &comment ) { mComment = comment; } QString Description::Entry::comment() const { return mComment; } void Description::Entry::setDefaultValue( const QString &value ) { mDefaultValue = value; } QString Description::Entry::defaultValue() const { return mDefaultValue; } bool Description::Entry::isGroup() const { return ( mEntryType == GroupType ); } kolabadmin/maintainer_record.cpp0000644000175000017500000001534310757564565016726 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "crypto.h" #include "tool.h" #include "maintainer_record.h" using namespace Form; Entry MaintainerRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); Entry entry = Entry::fromLdapEntry( response.entries().first() ); if ( entry.value( "givenName" ).isEmpty() ) { const QString cn = entry.value( "cn" ); const QString sn = entry.value( "sn" ); const QString givenName = cn.left( cn.length() - sn.length() ).trimmed(); entry.setValue( "givenName", givenName ); } return entry; } bool MaintainerRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QString dnRoot = QString( "cn=internal,%1" ).arg( Connection::self()->baseDn() ); QLdapEntry ldapEntry; ldapEntry.addValue( "objectClass", "top" ); ldapEntry.addValue( "objectClass", "inetOrgPerson" ); ldapEntry.addValue( "objectClass", "kolabInetOrgPerson" ); ldapEntry.setValue( "givenName", entry.value( "givenName" ) ); ldapEntry.setValue( "sn", entry.value( "sn" ) ); ldapEntry.setValue( "cn", QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ) ); if ( !entry.value( "password" ).isEmpty() ) { QByteArray data = "{sha}" + Crypto::sha1( entry.value( "password" ).toUtf8() ).toBase64(); ldapEntry.setValue( "userPassword", QString::fromUtf8( data ) ); } else { ldapEntry.setValue( "userPassword", entry.value( "userPassword" ) ); } ldapEntry.setValue( "uid", entry.value( "uid" ).toLower() ); if ( state == PagePolicy::Modify ) { QString newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * The 'cn' of the maintainer has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { /** * Add the object under the new dn... */ if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... and remove the object under the old dn. */ if ( !Connection::self()->remove( entry.id() ) ) { errorMsg = QObject::tr( "Could not modify maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * Add the new maintainer dn to the maintainer group... */ QString maintainerGroupDn = QString( "cn=maintainer,%1" ).arg( dnRoot ); QLdapEntry memberEntry; memberEntry.setValue( "member", newDn ); if ( !Connection::self()->addAttributes( maintainerGroupDn, memberEntry ) ) { errorMsg = QObject::tr( "Could not modify maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... and remove the old maintainer dn from the maintainer group. */ memberEntry.setValue( "member", entry.id() ); if ( !Connection::self()->removeAttributes( maintainerGroupDn, memberEntry ) ) { errorMsg = QObject::tr( "Could not modify maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } else { if ( !Connection::self()->modifyAttributes( entry.id(), ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * First add the maintainer... */ if ( !Connection::self()->add( dn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add maintainer '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... then add the maintainer dn to the maintainer group. */ QLdapEntry memberEntry; memberEntry.setDn( QString( "cn=maintainer,cn=internal,%1" ).arg( Connection::self()->baseDn() ) ); memberEntry.setValue( "member", dn ); if ( !Connection::self()->addAttributes( memberEntry.dn(), memberEntry ) ) { errorMsg = QObject::tr( "Could not add maintainer '%1' to group '%2': %3" ) .arg( entry.value( "cn" ), memberEntry.dn(), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Delete ) { /** * First remove maintainer dn from maintainer group... */ QLdapEntry memberEntry; memberEntry.setDn( QString( "cn=maintainer,cn=internal,%1" ).arg( Connection::self()->baseDn() ) ); memberEntry.setValue( "member", entry.id() ); if ( !Connection::self()->removeAttributes( memberEntry.dn(), memberEntry ) ) { errorMsg = QObject::tr( "Could not remove maintainer '%1' from group '%2': %3" ) .arg( entry.value( "cn" ), memberEntry.dn(), Connection::self()->errorString() ); return false; } /** * ... then remove the maintainer itself. */ QString ldapError; if ( !Tool::deleteObject( Connection::self(), entry.id(), ldapError ) ) { errorMsg = QObject::tr( "Could not remove maintainer '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/COPYING0000644000175000017500000004354110757564565013571 0ustar tobiastobiasNOTE! The GPL below is copyrighted by the Free Software Foundation, but the instance of code that it refers to (the kde programs) are copyrighted by the authors who actually wrote it. --------------------------------------------------------------------------- GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. kolabadmin/filterwidget.cpp0000644000175000017500000000537710757564565015740 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include "filtermodel.h" #include "tool.h" #include "filterwidget.h" FilterWidget::FilterWidget( FilterModel *model, QWidget *parent ) : QWidget( parent ), mModel( model ) { QGridLayout *layout = new QGridLayout( this ); mAttribute = new QComboBox( this ); mCriterion = new QComboBox( this ); mUserInput = new QLineEdit( this ); QPushButton *button = new QPushButton( tr( "&Filter" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( executeUserFilter() ) ); QLabel *label = new QLabel( tr( "Fi<er:" ), this ); label->setBuddy( mAttribute ); layout->addWidget( label, 0, 0 ); layout->addWidget( mAttribute, 0, 1 ); layout->addWidget( mCriterion, 0, 2 ); layout->addWidget( mUserInput, 0, 3 ); layout->addWidget( button, 0, 4 ); for ( int i = 0; i < mModel->rowCount(); ++i ) mAttribute->addItem( mModel->data( mModel->index( i, 0 ) ).toString() ); mCriterion->addItem( tr( "contains" ) ); mCriterion->addItem( tr( "is" ) ); mCriterion->addItem( tr( "begins with" ) ); mCriterion->addItem( tr( "ends with" ) ); } FilterWidget::~FilterWidget() { } void FilterWidget::executeUserFilter() { if ( mUserInput->text().isEmpty() ) { emit filter( QString() ); return; } FilterModel::FilterCriterion criterion; switch ( mCriterion->currentIndex() ) { case 1: criterion = FilterModel::FilterEquals; break; case 2: criterion = FilterModel::FilterStartsWith; break; case 3: criterion = FilterModel::FilterEndsWith; break; case 0: default: criterion = FilterModel::FilterContains; break; } const QString userInput = Tool::escape( mUserInput->text() ); emit filter( mModel->filter( mModel->index( mAttribute->currentIndex(), 0 ), userInput, criterion ) ); } void FilterWidget::executeAlphaFilter() { } kolabadmin/ldapsearchdialog.h0000644000175000017500000000425610757564565016175 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LDAPSEARCHDIALOG_H #define LDAPSEARCHDIALOG_H #include "qldap.h" #include class LdapSearchDialog : public QDialog { Q_OBJECT public: LdapSearchDialog( QLdap* connection, QWidget *parent = 0 ); ~LdapSearchDialog(); /** * Sets the filter for this search. * * The filter can be any LDAP filter with %i as replacement * for the input of the user. * * Example: * setSearchFilter( "(|(uid=%i)(mail=%i))" ) */ void setSearchFilter( const QString &searchFilter ); /** * Sets the display format. * * The display format is used in the result view to * reformat the entries. * * Example: * setDisplayFormat( "%givenName% %sn%" ); */ void setDisplayFormat( const QString &displayFormat ); void setBlackList( const QStringList &blacklist ); /** * Returns a list of values for the given key the user selected. * * Example: * QStringList emails = dlg.selectedValues( "mail" ); * * will return the email addresses of all selected entries */ QStringList selectedValues( const QString& key ) const; /** * Returns a list of all selected ldap entries. */ QLdapEntry::List selectedEntries() const; public slots: void search(); private: class Private; Private *d; }; #endif kolabadmin/dialog.cpp0000644000175000017500000000550010757564565014472 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "connection.h" #include "record.h" #include "dialog.h" using namespace Form; Dialog::Dialog( Page *page, const QString &id, PagePolicy::State state, QWidget *parent ) : QDialog( parent ), mPage( page ), mId( id ), mState( state ) { // set window title QString title; if ( state == PagePolicy::Add ) title = tr( "Add: " ); else if ( state == PagePolicy::Modify ) title = tr( "Modify: " ); else title = tr( "Delete: " ); title += page->title(); setWindowTitle( title ); // create gui mContainer = new Container( page->name(), this ); QGridLayout *layout = new QGridLayout( this ); layout->addWidget( mContainer, 0, 0, 1, 3 ); QPushButton *button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 1, 1 ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 1, 2 ); Description *description = mPage->formDescription(); if ( description ) { mContainer->build( description, mPage->formPolicy(), mState ); } Record *record = mPage->formRecord(); if ( record ) { Entry entry = record->loadEntry( mId, mState ); mContainer->loadEntry( entry ); } } void Dialog::accept() { QString msg; if ( !mContainer->isValid( msg, mState ) ) { QMessageBox::warning( this, tr( "Form not valid" ), msg ); return; } Entry entry; entry.setId( mId ); /** * Fill the entry with the original values in Modify state. */ if ( mState == PagePolicy::Modify ) { entry = mPage->formRecord()->loadEntry( mId, mState ); entry.dump(); } mContainer->saveEntry( entry ); Record *record = mPage->formRecord(); if ( record ) { QString errorMsg; if ( !record->saveEntry( entry, mState, errorMsg ) ) { QMessageBox::critical( this, QString(), errorMsg ); return; } } done( Accepted ); } kolabadmin/accounttypefield.cpp0000644000175000017500000000437110757564565016602 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "accounttypefield.h" using namespace Form; AccountTypeField::AccountTypeField( const QString &name, QWidget *parent ) : Field( name, parent ) { mComboBox = new QComboBox( this ); mComboBox->addItem( tr( "User Account" ) ); mComboBox->addItem( tr( "Internal User Account" ) ); mComboBox->addItem( tr( "Group Account" ) ); mComboBox->addItem( tr( "Resource Account" ) ); fieldLayout()->addWidget( mComboBox, 0, 0 ); } void AccountTypeField::loadEntry( const Entry &entry ) { if ( entry.value( "accttype" ) == "user" ) mComboBox->setCurrentIndex( 0 ); else if ( entry.value( "accttype" ) == "internalUser" ) mComboBox->setCurrentIndex( 1 ); else if ( entry.value( "accttype" ) == "group" ) mComboBox->setCurrentIndex( 2 ); else if ( entry.value( "accttype" ) == "resource" ) mComboBox->setCurrentIndex( 3 ); } void AccountTypeField::saveEntry( Entry &entry ) const { switch ( mComboBox->currentIndex() ) { case 0: entry.setValue( "accttype", "user" ); break; case 1: entry.setValue( "accttype", "internalUser" ); break; case 2: entry.setValue( "accttype", "group" ); break; case 3: entry.setValue( "accttype", "resource" ); break; } } bool AccountTypeField::isValid( QString&, PagePolicy::State ) const { return true; } void AccountTypeField::setEditable( bool editable ) { mComboBox->setEnabled( editable ); } kolabadmin/service_record.h0000644000175000017500000000221610757564565015677 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SERVICE_RECORD_H #define FORM_SERVICE_RECORD_H #include "record.h" namespace Form { class ServiceRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/addressbook_description.cpp0000644000175000017500000000726010757564565020143 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_description.h" using namespace Form; Description::Entry::List AddressBookDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "givenName" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "First Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "sn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Last Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "title" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Title" ) ); entries.append( entry ); } { Entry entry; entry.setName( "mail" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Primary Email Address" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } { Entry entry; entry.setName( "alias" ); entry.setType( "alias" ); entry.setLabel( QObject::tr( "Email Aliases" ) ); entries.append( entry ); } { Entry entry; entry.setName( "o" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Organisation" ) ); entries.append( entry ); } { Entry entry; entry.setName( "ou" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Organisational Unit" ) ); entries.append( entry ); } { Entry entry; entry.setName( "roomNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Room Number" ) ); entries.append( entry ); } { Entry entry; entry.setName( "street" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Street Address" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postOfficeBox" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Postbox" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postalCode" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Postal Code" ) ); entries.append( entry ); } { Entry entry; entry.setName( "l" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "City" ) ); entries.append( entry ); } { Entry entry; entry.setName( "c" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Country" ) ); entries.append( entry ); } { Entry entry; entry.setName( "telephoneNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Telephone Number" ) ); entries.append( entry ); } { Entry entry; entry.setName( "facsimileTelephoneNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Fax Number" ) ); entries.append( entry ); } return entries; } kolabadmin/sharedfolder_record.h0000644000175000017500000000223510757564565016702 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SHAREDFOLDER_RECORD_H #define FORM_SHAREDFOLDER_RECORD_H #include "record.h" namespace Form { class SharedFolderRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/passwordfield.cpp0000644000175000017500000000425010757564565016102 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "passwordfield.h" using namespace Form; PasswordField::PasswordField( const QString &name, QWidget *parent ) : Field( name, parent ) { mPassword = new QLineEdit( this ); mPassword->setEchoMode( QLineEdit::Password ); QLabel *label = new QLabel( tr( " Verify: " ), this ); mPasswordVerify = new QLineEdit( this ); mPasswordVerify->setEchoMode( QLineEdit::Password ); fieldLayout()->addWidget( mPassword, 0, 0 ); fieldLayout()->addWidget( label, 0, 1, Qt::AlignRight ); fieldLayout()->addWidget( mPasswordVerify, 0, 2 ); } void PasswordField::loadEntry( const Entry& ) { } void PasswordField::saveEntry( Entry &entry ) const { if ( !mPassword->text().isEmpty() ) entry.setValue( name(), mPassword->text() ); } bool PasswordField::isValid( QString &msg, PagePolicy::State state ) const { if ( state == PagePolicy::Add ) { if ( mPassword->text().isEmpty() ) { msg = tr( "Password is empty" ); return false; } } if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { if ( mPassword->text() != mPasswordVerify->text() ) { msg = tr( "Passwords dont match" ); return false; } } return true; } void PasswordField::setEditable( bool editable ) { mPassword->setReadOnly( !editable ); mPasswordVerify->setReadOnly( !editable ); } kolabadmin/ChangeLog0000644000175000017500000000135110757564565014301 0ustar tobiastobias2006-11-03 Tobias Koenig * Applyed patch written by Andrew J. Kopciuch which adds sorting to the listings * Fixed bug in creation of distribution lists 2006-09-05 Tobias Koenig * Extract the given name from the cn attribute to be standard conform with Kolab 2006-08-25 Tobias Koenig * Add support for correct installation 2006-06-29 Tobias Koenig * Use sha1 encrypted passwords for administrators and maintainers as well 2006-06-14 Tobias Koenig * Replaced dependency to libcrypt with dependency to libopenssl for stronger password encryption 2006-06-13 Tobias Koenig * Initial published version kolabadmin/invitationpolicyfield.cpp0000644000175000017500000001747410757564565017660 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include "itemview.h" #include "invitationpolicyfield.h" using namespace Form; class InvitationPolicyModel : public QAbstractListModel { public: InvitationPolicyModel( QObject *parent = 0 ) : QAbstractListModel( parent ) { } virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const { return 1; } virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const { return mList.count(); } virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) return mList[ index.row() ].displayName; else if ( role == Qt::UserRole ) return mList[ index.row() ].pair; else return QVariant(); } virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) { if ( !index.isValid() ) { return false; } if ( !value.isValid() ) return false; if ( role == Qt::UserRole ) { static QMap policyMap; if ( policyMap.isEmpty() ) { policyMap.insert( "ACT_ALWAYS_ACCEPT", tr( "Always accept" ) ); policyMap.insert( "ACT_ALWAYS_REJECT", tr( "Always reject" ) ); policyMap.insert( "ACT_REJECT_IF_CONFLICTS", tr( "Reject if conflicts" ) ); policyMap.insert( "ACT_MANUAL_IF_CONFLICTS", tr( "Manual if conflicts" ) ); policyMap.insert( "ACT_MANUAL", tr( "Manual" ) ); } QStringList pair = value.toStringList(); mList[ index.row() ].pair = pair; mList[ index.row() ].displayName = QString( "%1 (%2)" ).arg( pair[ 0 ], policyMap[ pair[ 1 ] ] ); } return true; } virtual bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginInsertRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.insert( row, Entry() ); endInsertRows(); return true; } virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginRemoveRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.removeAt( row ); endRemoveRows(); return true; } private: class Entry { public: QString displayName; QStringList pair; }; QList mList; }; class InvitationPolicyDialog : public QDialog { public: InvitationPolicyDialog( QWidget *parent ) : QDialog( parent ) { QGridLayout *layout = new QGridLayout( this ); QLabel *label = new QLabel( tr( "Email Address:" ), this ); layout->addWidget( label, 0, 0 ); mMail = new QLineEdit( this ); label->setBuddy( mMail ); layout->addWidget( mMail, 0, 1, 1, 3 ); label = new QLabel( tr( "Policy:" ), this ); layout->addWidget( label, 1, 0 ); mPolicy = new QComboBox( this ); mPolicy->addItem( tr( "Always accept" ) ); mPolicy->addItem( tr( "Always reject" ) ); mPolicy->addItem( tr( "Reject if conflicts" ) ); mPolicy->addItem( tr( "Manual if conflicts" ) ); mPolicy->addItem( tr( "Manual" ) ); label->setBuddy( mPolicy ); layout->addWidget( mPolicy, 1, 1, 1, 3 ); QPushButton *button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 2, 2 ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 2, 3 ); } virtual void accept() { if ( mMail->text().isEmpty() ) { QMessageBox::warning( this, QString(), tr( "No email address set!" ) ); return; } done( Accepted ); } QStringList pair() const { QStringList pair; pair.append( mMail->text() ); switch ( mPolicy->currentIndex() ) { case 0: pair.append( "ACT_ALWAYS_ACCEPT" ); break; case 1: pair.append( "ACT_ALWAYS_REJECT" ); break; case 2: pair.append( "ACT_REJECT_IF_CONFLICTS" ); break; case 3: pair.append( "ACT_MANUAL_IF_CONFLICTS" ); break; case 4: pair.append( "ACT_MANUAL" ); break; } return pair; } private: QLineEdit* mMail; QComboBox* mPolicy; }; class InvitationPolicyItemView : public ItemView { public: InvitationPolicyItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { InvitationPolicyDialog dlg( this ); if ( dlg.exec() ) { QStringList pair = dlg.pair(); QAbstractItemModel *model = mListView->model(); // check whether rule is already part of the model bool found = false; for ( int k = 0; k < model->rowCount(); ++k ) { QStringList modelPair = model->data( model->index( k, 0 ), Qt::UserRole ).toStringList(); if ( pair[ 0 ] == modelPair[ 0 ] && pair[ 1 ] == modelPair[ 1 ] ) { found = true; break; } } if ( !found ) { int row = model->rowCount(); model->insertRow( row ); model->setData( model->index( row, 0 ), pair, Qt::UserRole ); } } } }; InvitationPolicyField::InvitationPolicyField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new InvitationPolicyItemView( this ); mModel = new InvitationPolicyModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void InvitationPolicyField::loadEntry( const Entry &entry ) { QStringList invitationPolicies = entry.values( "kolabInvitationPolicy" ); for ( int i = 0; i < invitationPolicies.count(); ++i ) { QString policy = invitationPolicies[ i ]; QStringList pair; if ( policy.contains( ':' ) ) { pair = policy.split( ":" ); } else { pair.append( "anyone" ); pair.append( policy ); } mModel->insertRow( i ); mModel->setData( mModel->index( i, 0 ), pair, Qt::UserRole ); } } void InvitationPolicyField::saveEntry( Entry &entry ) const { entry.clearValue( "kolabInvitationPolicy" ); for ( int i = 0; i < mModel->rowCount(); ++i ) { QStringList pair = mModel->data( mModel->index( i, 0 ), Qt::UserRole ).toStringList(); if ( pair[ 0 ] == "anyone" ) entry.addValue( "kolabInvitationPolicy", pair[ 1 ] ); else entry.addValue( "kolabInvitationPolicy", QString( "%1:%2" ).arg( pair[ 0 ], pair[ 1 ] ) ); } } bool InvitationPolicyField::isValid( QString &message, PagePolicy::State ) const { return true; } void InvitationPolicyField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/fieldfactory.cpp0000644000175000017500000000567010757564565015716 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "fieldfactory.h" #include "accounttypefield.h" #include "aclselectionfield.h" #include "aliasfield.h" #include "booleanfield.h" #include "delegatefield.h" #include "hostsfield.h" #include "integerfield.h" #include "invitationpolicyfield.h" #include "mailfilterfield.h" #include "memberselectionfield.h" #include "networksfield.h" #include "passwordfield.h" #include "servicesfield.h" #include "smtphostfield.h" #include "stringfield.h" using namespace Form; FieldFactory *FieldFactory::mSelf = 0; FieldFactory::FieldFactory() { } FieldFactory::~FieldFactory() { } FieldFactory *FieldFactory::self() { if ( !mSelf ) mSelf = new FieldFactory; return mSelf; } Field *FieldFactory::createField( const QString &type, const QString &name, QWidget *parent ) const { if ( type == "accounttype" ) return new AccountTypeField( name, parent ); if ( type == "aclselection" ) return new AclSelectionField( name, parent ); if ( type == "alias" ) return new AliasField( name, parent ); if ( type == "boolean" ) return new BooleanField( name, parent ); if ( type == "delegate" ) return new DelegateField( name, parent ); if ( type == "hosts" ) return new HostsField( name, parent ); if ( type == "integer" ) return new IntegerField( name, parent ); if ( type == "invitationpolicy" ) return new InvitationPolicyField( name, parent ); if ( type == "mailfilter" ) return new MailFilterField( name, parent ); if ( type == "memberselection" ) return new MemberSelectionField( name, parent ); if ( type == "networks" ) return new NetworksField( name, parent ); if ( type == "non-empty-string" ) return new StringField( name, StringField::InvalidateEmpty, parent ); if ( type == "password" ) return new PasswordField( name, parent ); if ( type == "smtphost" ) return new SmtpHostField( name, parent ); if ( type == "string" ) return new StringField( name, StringField::ValidateEmpty, parent ); if ( type == "services" ) return new ServicesField( name, parent ); qDebug( "FieldFactory: Unknown field type '%s'", qPrintable( type ) ); return 0; } kolabadmin/mainwindow.cpp0000644000175000017500000000242110757564565015406 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "mainwidget.h" #include "mainwindow.h" MainWindow::MainWindow( QWidget *parent ) : QMainWindow( parent ) { setCentralWidget( new MainWidget( this ) ); resize( 500, 540 ); QAction* quitAction = new QAction( tr( "&Quit" ), this ); quitAction->setShortcut( Qt::CTRL + Qt::Key_Q ); connect( quitAction, SIGNAL( triggered( bool ) ), qApp, SLOT( quit() ) ); addAction( quitAction ); } kolabadmin/networksfield.cpp0000644000175000017500000000562710757564565016125 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "itemview.h" #include "networksfield.h" using namespace Form; class NetworkModel : public QStringListModel { public: NetworkModel( QObject *parent = 0 ) : QStringListModel( parent ) { } virtual Qt::ItemFlags flags( const QModelIndex& ) const { return ( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } }; class NetworkItemView : public ItemView { public: NetworkItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { bool ok = true; QString network = QInputDialog::getText( this, tr( "New Network" ), tr( "Network:" ), QLineEdit::Normal, QString(), &ok ); if ( ok && !network.isEmpty() ) { QAbstractItemModel *model = mListView->model(); bool found = false; for ( int i = 0; i < model->rowCount(); ++i ) { if ( network == model->data( model->index( i, 0 ), Qt::DisplayRole ).toString() ) { found = true; break; } } if ( !found ) { int pos = model->rowCount(); model->insertRow( pos ); model->setData( model->index( pos, 0 ), network ); } } } }; NetworksField::NetworksField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new NetworkItemView( this ); mModel = new NetworkModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void NetworksField::loadEntry( const Entry &entry ) { mModel->setStringList( entry.values( "postfix-mynetworks" ) ); } void NetworksField::saveEntry( Entry &entry ) const { entry.clearValue( "postfix-mynetworks" ); const QStringList networks = mModel->stringList(); for ( int i = 0; i < networks.count(); ++i ) { entry.addValue( "postfix-mynetworks", networks[ i ] ); } } bool NetworksField::isValid( QString&, PagePolicy::State ) const { return true; } void NetworksField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/listingwidget.h0000644000175000017500000000250710757564565015561 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LISTINGWIDGET_H #define LISTINGWIDGET_H #include class ListingModel; class ListingWidget : public QTextBrowser { Q_OBJECT public: ListingWidget( QWidget *parent ); void setModel( ListingModel *model ); Q_SIGNALS: void addEntry(); void modifyEntry( const QString &id ); void deleteEntry( const QString &id ); public Q_SLOTS: void setSource( const QUrl &name ); private Q_SLOTS: void update(); private: ListingModel *mModel; }; #endif kolabadmin/service_policy.h0000644000175000017500000000231610757564565015721 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SERVICE_POLICY_H #define FORM_SERVICE_POLICY_H #include "pagepolicy.h" namespace Form { class ServicePolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/memberselectionfield.h0000644000175000017500000000257110757564565017066 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_MEMBERSELECTIONFIELD_H #define FORM_MEMBERSELECTIONFIELD_H #include "field.h" class ItemView; class MemberModel; namespace Form { class MemberSelectionField : public Field { public: MemberSelectionField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView* mView; MemberModel* mModel; }; } #endif kolabadmin/sharedfolder_policy.h0000644000175000017500000000233510757564565016724 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SHAREDFOLDER_POLICY_H #define FORM_SHAREDFOLDER_POLICY_H #include "pagepolicy.h" namespace Form { class SharedFolderPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/administrator_description.h0000644000175000017500000000207110757564565020163 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADMINISTRATOR_DESCRIPTION_H #define FORM_ADMINISTRATOR_DESCRIPTION_H #include "description.h" namespace Form { class AdministratorDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/listingdialog.cpp0000644000175000017500000000520510757564565016066 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "dialog.h" #include "pagepolicy.h" #include "filtermodel.h" #include "filterwidget.h" #include "listingwidget.h" #include "listingmodel.h" #include "listingdialog.h" ListingDialog::ListingDialog( Page *page, QWidget *parent ) : QDialog( parent ), mPage( page ) { setWindowTitle( page->title() ); mModel = page->model(); QGridLayout *layout = new QGridLayout( this ); FilterModel *filterModel = mModel->filterModel(); if ( filterModel ) { FilterWidget *filterWidget = new FilterWidget( filterModel, this ); layout->addWidget( filterWidget, 0, 0, 1, 3 ); connect( filterWidget, SIGNAL( filter( const QString& ) ), mModel, SLOT( query( const QString& ) ) ); } ListingWidget *widget = new ListingWidget( this ); layout->addWidget( widget, 1, 0, 1, 3 ); connect( widget, SIGNAL( addEntry() ), this, SLOT( addEntry() ) ); connect( widget, SIGNAL( modifyEntry( const QString& ) ), this, SLOT( modifyEntry( const QString& ) ) ); connect( widget, SIGNAL( deleteEntry( const QString& ) ), this, SLOT( deleteEntry( const QString& ) ) ); QPushButton *button = new QPushButton( tr( "&Close" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 2, 2 ); widget->setModel( mModel ); mModel->query(); resize( 800, 500 ); } void ListingDialog::addEntry() { Form::Dialog dlg( mPage, QString(), Form::PagePolicy::Add, this ); if ( dlg.exec() ) mModel->query(); } void ListingDialog::modifyEntry( const QString &id ) { Form::Dialog dlg( mPage, id, Form::PagePolicy::Modify, this ); if ( dlg.exec() ) mModel->query(); } void ListingDialog::deleteEntry( const QString &id ) { Form::Dialog dlg( mPage, id, Form::PagePolicy::Delete, this ); if ( dlg.exec() ) mModel->query(); } kolabadmin/maintainer_description.cpp0000644000175000017500000000361510757564565017772 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "maintainer_description.h" using namespace Form; Description::Entry::List MaintainerDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "givenName" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "First Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "sn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Last Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "password" ); entry.setType( "password" ); entry.setLabel( QObject::tr( "Password" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "uid" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Unique Identity (UID)" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } return entries; } kolabadmin/distributionlist_policy.cpp0000644000175000017500000000234610757564565020232 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "distributionlist_policy.h" using namespace Form; bool DistributionListPolicy::fieldEditable( State state, const QString& ) const { if ( state == Add || state == Modify ) return true; else return false; } bool DistributionListPolicy::fieldVisible( State, const QString& ) const { return true; } bool DistributionListPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/aliasfield.cpp0000644000175000017500000000654710757564565015344 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "connection.h" #include "itemview.h" #include "tool.h" #include "aliasfield.h" using namespace Form; class AliasModel : public QStringListModel { public: AliasModel( QObject *parent = 0 ) : QStringListModel( parent ) { } virtual Qt::ItemFlags flags( const QModelIndex& ) const { return ( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } }; class AliasItemView : public ItemView { public: AliasItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { bool ok = true; QString mail = QInputDialog::getText( this, tr( "New Email Alias" ), tr( "Email Alias:" ), QLineEdit::Normal, QString(), &ok ); if ( ok && !mail.isEmpty() ) { QAbstractItemModel *model = mListView->model(); bool found = false; for ( int i = 0; i < model->rowCount(); ++i ) { if ( mail == model->data( model->index( i, 0 ), Qt::DisplayRole ).toString() ) { found = true; break; } } if ( !found ) { int pos = model->rowCount(); model->insertRow( pos ); model->setData( model->index( pos, 0 ), mail ); } } } }; AliasField::AliasField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new AliasItemView( this ); mModel = new AliasModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void AliasField::loadEntry( const Entry &entry ) { mModel->setStringList( entry.values( "alias" ) ); mDn = entry.id(); } void AliasField::saveEntry( Entry &entry ) const { entry.clearValue( "alias" ); const QStringList alias = mModel->stringList(); for ( int i = 0; i < alias.count(); ++i ) { entry.addValue( "alias", alias[ i ] ); } } bool AliasField::isValid( QString &message, PagePolicy::State ) const { /** * We have to make sure that no other entry in the LDAP has already one * of our alias set. */ const QStringList aliasList = mModel->stringList(); for ( int i = 0; i < aliasList.count(); ++i ) { const QString alias = aliasList[ i ]; if ( Tool::numberOfMails( Connection::self(), Connection::self()->baseDn(), alias, QStringList( mDn ) ) > 0 ) { message = QObject::tr( "Alias '%1' already exists." ).arg( alias ); return false; } } return true; } void AliasField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/auth.cpp0000644000175000017500000000450310757564565014176 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "auth.h" Auth* Auth::mSelf = 0; class Auth::Private { public: QString dn; QString uid; Group group; }; Auth::Auth() : d( new Private ) { } Auth::~Auth() { delete d; d = 0; } Auth* Auth::self() { if ( !mSelf ) mSelf = new Auth; return mSelf; } bool Auth::authenticate( const QString &dn, QString &errorMsg ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( dn, QLdap::Sub, filter ); if ( !response.isValid() ) { errorMsg = Connection::self()->errorString(); return false; } if ( response.entries().isEmpty() ) { errorMsg = QObject::tr( "Unknown user" ); return false; } QLdapEntry entry = response.entries().first(); d->dn = entry.dn(); d->uid = entry.value( "uid" ); Group group( Users ); filter = QString( "(member=%1)" ).arg( dn ); QString baseDn = QString( "cn=maintainer,cn=internal,%1" ).arg( Connection::self()->baseDn() ); response = Connection::self()->search( baseDn, QLdap::Base, filter ); if ( !response.entries().isEmpty() ) group = Maintainers; baseDn = QString( "cn=admin,cn=internal,%1" ).arg( Connection::self()->baseDn() ); response = Connection::self()->search( baseDn, QLdap::Base, filter ); if ( !response.entries().isEmpty() ) group = Administrators; d->group = group; return true; } QString Auth::dn() const { return d->dn; } QString Auth::uid() const { return d->uid; } Auth::Group Auth::group() const { return d->group; } kolabadmin/pagepolicy.h0000644000175000017500000000366510757564565015046 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_PAGEPOLICY_H #define FORM_PAGEPOLICY_H #include namespace Form { class PagePolicy { public: /** * There are 3 states the form can be in: * - Add When a new entry is added. * - Modify When an existing entry is modified. * - Delete When an existing entry shall be deleted. */ enum State { Add, Modify, Delete }; /** * Creates a new PagePolicy object which returns 'true' for all * check functions. */ PagePolicy(); virtual ~PagePolicy(); /** * Returns whether the field with the given name is editable in the * given state. */ virtual bool fieldEditable( State state, const QString &name ) const; /** * Returns whether the field with the given name is visible in the * given state. */ virtual bool fieldVisible( State state, const QString &name ) const; /** * Returns whether the whole container with the given name is * editable in the given state. */ virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/distributionlist_filtermodel.h0000644000175000017500000000240510757564565020702 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DISTRIBUTIONLIST_FILTERMODEL_H #define DISTRIBUTIONLIST_FILTERMODEL_H #include "filtermodel.h" class DistributionListFilterModel : public FilterModel { public: DistributionListFilterModel( QObject *parent = 0 ); virtual ~DistributionListFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/connectioninfomanager.cpp0000644000175000017500000001111610757564565017601 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "connectioninfomanager.h" ConnectionInfo::ConnectionInfo() { } ConnectionInfo::ConnectionInfo( const QString &name ) : mName( name ) { } QString ConnectionInfo::name() const { return mName; } bool ConnectionInfo::isValid() const { return ( !mName.isEmpty() && !mHost.isEmpty() && !mBaseDn.isEmpty() && !mNobodyUser.isEmpty() && !mNobodyPassword.isEmpty() ); } void ConnectionInfo::setHost( const QString &host ) { mHost = host; } QString ConnectionInfo::host() const { return mHost; } void ConnectionInfo::setPort( int port ) { mPort = port; } int ConnectionInfo::port() const { return mPort; } void ConnectionInfo::setBaseDn( const QString &baseDn ) { mBaseDn = baseDn; } QString ConnectionInfo::baseDn() const { return mBaseDn; } void ConnectionInfo::setNobodyUser( const QString &nobodyUser ) { mNobodyUser = nobodyUser; } QString ConnectionInfo::nobodyUser() const { return mNobodyUser; } void ConnectionInfo::setNobodyPassword( const QString &nobodyPassword ) { mNobodyPassword = nobodyPassword; } QString ConnectionInfo::nobodyPassword() const { return mNobodyPassword; } ConnectionInfoManager::ConnectionInfoManager() { } ConnectionInfo::List ConnectionInfoManager::connectionInfos() const { return mConnectionInfos; } ConnectionInfo ConnectionInfoManager::connectionInfo( const QString &name ) const { for ( int i = 0; i < mConnectionInfos.count(); ++i ) if ( mConnectionInfos[ i ].name() == name ) return mConnectionInfos[ i ]; return ConnectionInfo(); } bool ConnectionInfoManager::contains( const QString &name ) const { for ( int i = 0; i < mConnectionInfos.count(); ++i ) if ( mConnectionInfos[ i ].name() == name ) return true; return false; } void ConnectionInfoManager::appendConnectionInfo( const ConnectionInfo &connection ) { if ( !contains( connection.name() ) ) mConnectionInfos.append( connection ); } void ConnectionInfoManager::removeConnectionInfo( const QString &name ) { for ( int i = 0; i < mConnectionInfos.count(); ++i ) if ( mConnectionInfos[ i ].name() == name ) { mConnectionInfos.removeAt( i ); return; } } void ConnectionInfoManager::load() { mConnectionInfos.clear(); QSettings settings( "Kolab", "KolabAdmin" ); settings.beginGroup( "connections" ); const QStringList groups = settings.childGroups(); for ( int i = 0; i < groups.count(); ++i ) { settings.beginGroup( groups[ i ] ); ConnectionInfo connection( settings.value( "name" ).toString() ); connection.setHost( settings.value( "host" ).toString() ); connection.setPort( settings.value( "port" ).toInt() ); connection.setBaseDn( settings.value( "basedn" ).toString() ); connection.setNobodyUser( settings.value( "nobody_user" ).toString() ); connection.setNobodyPassword( settings.value( "nobody_password" ).toString() ); settings.endGroup(); mConnectionInfos.append( connection ); } settings.endGroup(); } void ConnectionInfoManager::save() { QSettings settings( "Kolab", "KolabAdmin" ); // delete old settings settings.remove( "connections" ); // write new settings settings.beginGroup( "connections" ); for ( int i = 0; i < mConnectionInfos.count(); ++i ) { settings.beginGroup( QString::number( i ) ); settings.setValue( "name", mConnectionInfos[ i ].name() ); settings.setValue( "host", mConnectionInfos[ i ].host() ); settings.setValue( "port", mConnectionInfos[ i ].port() ); settings.setValue( "basedn", mConnectionInfos[ i ].baseDn() ); settings.setValue( "nobody_user", mConnectionInfos[ i ].nobodyUser() ); settings.setValue( "nobody_password", mConnectionInfos[ i ].nobodyPassword() ); settings.endGroup(); } settings.endGroup(); settings.sync(); } kolabadmin/application.qrc0000644000175000017500000000077010757564565015545 0ustar tobiastobias pics/addressbook.png pics/administrator.png pics/distributionlist.png pics/maintainer.png pics/service.png pics/sharedfolder.png pics/user.png pics/kolab_logo.png kolabadmin/accounttypefield.h0000644000175000017500000000250310757564565016242 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ACCOUNTTYPEFIELD_H #define FORM_ACCOUNTTYPEFIELD_H #include "field.h" class QComboBox; namespace Form { class AccountTypeField : public Field { public: AccountTypeField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QComboBox* mComboBox; }; } #endif kolabadmin/passwordfield.h0000644000175000017500000000252710757564565015554 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_PASSWORDFIELD_H #define FORM_PASSWORDFIELD_H #include "field.h" class QLineEdit; namespace Form { class PasswordField : public Field { public: PasswordField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QLineEdit* mPassword; QLineEdit* mPasswordVerify; }; } #endif kolabadmin/sharedfolder_listingmodel.cpp0000644000175000017500000000614510757564565020455 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "sharedfolder_filtermodel.h" #include "sharedfolder_listingmodel.h" void SharedFolderListingModel::doQuery( const QString &userFilter ) { QString filter = QString( "(&(cn=*)%1(objectClass=kolabSharedFolder))" ).arg( userFilter ); mData = Connection::self()->search( QString(), QLdap::Sub, filter ); emit layoutChanged(); } int SharedFolderListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 2; } int SharedFolderListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant SharedFolderListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return entry.value( "cn" ); break; case 1: return entry.value( "kolabHomeServer" ); break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return true; else return false; } else if ( role == ModifyActionLabelRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return tr( "Modify" ); else return tr( "Shared folder deleted, awaiting cleanup..." ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return mData.entries()[ index.row() ].dn(); else return QString(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant SharedFolderListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Name" ); break; case 1: return tr( "Server" ); break; default: return QVariant(); } } FilterModel* SharedFolderListingModel::filterModel() { return new SharedFolderFilterModel( this ); } kolabadmin/tool.cpp0000644000175000017500000001277110757564565014220 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "qldap.h" #include "tool.h" static bool deleteCommonObject( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow, bool nukePassword ) { if ( deleteNow ) { if ( !connection->remove( dn ) ) { errorMsg = connection->errorString(); return false; } } else { const QLdapEntry kolabEntry = Tool::kolabSettings( connection ); QLdapEntry entry; /** * Set all defined kolabHosts in the kolabDeleteflag. */ QStringList kolabHosts = kolabEntry.values( "kolabHost" ); for ( int i = 0; i < kolabHosts.count(); ++i ) entry.addValue( "kolabDeleteflag", kolabHosts[ i ] ); /** * To block the login of a deleted object between the deletion and the cleanup * we fill the password with random garbage. */ if ( nukePassword ) { entry.setValue( "userPassword", QString( "{sha}%1" ).arg( Tool::randomString( 32 ) ) ); } if ( !connection->modifyAttributes( dn, entry ) ) { errorMsg = connection->errorString(); return false; } } return true; } int Tool::numberOfMails( QLdap* connection, const QString &baseDn, const QString &email, const QStringList &excludedDns ) { /** * At first count the matching users... */ const QString filter = QString( "(|(mail=%1)(alias=%2)(uid=%3))" ).arg( email, email, email ); const QStringList attributes( "dn" ); const QLdapResponse response = connection->search( baseDn, QLdap::Sub, filter, attributes ); int count = 0; const QLdapEntry::List entries = response.entries(); if ( !excludedDns.isEmpty() ) { for ( int i = 0; i < entries.count(); ++i ) { if ( excludedDns.contains( entries[ i ].dn() ) ) continue; count++; } } else count += entries.count(); return count; }; QString Tool::dnForMailOrAlias( QLdap* connection, const QString &value ) { const QString filter = QString( "(&(objectClass=kolabInetOrgPerson)(|(mail=%1)(alias=%2)))" ).arg( value, value ); const QStringList attributes( "dn" ); const QLdapResponse response = connection->search( connection->baseDn(), QLdap::Sub, filter, attributes ); if ( !response.isValid() || response.entries().isEmpty() ) return QString(); return response.entries().first().dn(); } bool Tool::deleteObject( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow ) { return deleteCommonObject( connection, dn, errorMsg, deleteNow, true ); } bool Tool::deleteSharedFolder( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow ) { return deleteCommonObject( connection, dn, errorMsg, deleteNow, false ); } bool Tool::deleteGroupOfNames( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow ) { return deleteCommonObject( connection, dn, errorMsg, deleteNow, false ); } QLdapEntry Tool::kolabSettings( QLdap* connection ) { const QString filter = QString( "objectClass=*" ); const QString dn = QString( "k=kolab,%1" ).arg( connection->baseDn() ); const QLdapResponse response = connection->search( dn, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return QLdapEntry(); return response.entries().first(); } QString Tool::randomString( int length ) { const QString characters( "abcdefghijklmnopqrstuvwABCDEFGHIJKLMNOPQRSTUVW0123456789" ); // initiate seed qsrand( QTime::currentTime().msec() ); QString retval; for ( int i = 0; i < length; ++i ) { retval.append( characters[ qrand() % 56 ] ); } return retval; } QString Tool::escape( const QString &value ) { /** From RFC-2254: If a value should contain any of the following characters Character ASCII value --------------------------- * 0x2a ( 0x28 ) 0x29 \ 0x5c NUL 0x00 the character must be encoded as the backslash '\' character (ASCII 0x5c) followed by the two hexadecimal digits representing the ASCII value of the encoded character. The case of the two hexadecimal digits is not significant. */ QString retval( value ); retval.replace( '\\', QChar( 0x5c ) ); retval.replace( '*', QChar( 0x2a ) ); retval.replace( '(', QChar( 0x28 ) ); retval.replace( ')', QChar( 0x29 ) ); retval.replace( '\0', QChar( 0x00 ) ); return retval; } QString Tool::escapeDn( const QString &dn ) { /** DN component escaping as described in RFC-2253 */ QString retval( dn ); retval.replace( '\\', "\\\\" ); retval.replace( ',', "\\," ); retval.replace( '+', "\\," ); retval.replace( '<', "\\<" ); retval.replace( '>', "\\>" ); retval.replace( ';', "\\;" ); if ( retval.startsWith( '#' ) ) retval.prepend( '\\' ); return retval; } kolabadmin/distributionlist_record.h0000644000175000017500000000232510757564565017653 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DISTRIBUTIONLIST_RECORD_H #define FORM_DISTRIBUTIONLIST_RECORD_H #include "record.h" namespace Form { class DistributionListRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); private: QString mailDomain() const; }; } #endif kolabadmin/kolabadmin.pro0000644000175000017500000000531310757564565015354 0ustar tobiastobiasTEMPLATE=app TARGET=kolabadmin DESCRIPTION_SOURCES=description.cpp \ addressbook_description.cpp \ administrator_description.cpp \ distributionlist_description.cpp \ maintainer_description.cpp \ service_description.cpp \ sharedfolder_description.cpp \ user_description.cpp FIELD_SOURCES=field.cpp \ accounttypefield.cpp \ aclselectionfield.cpp \ aliasfield.cpp \ booleanfield.cpp \ delegatefield.cpp \ hostsfield.cpp \ integerfield.cpp \ invitationpolicyfield.cpp \ mailfilterfield.cpp \ memberselectionfield.cpp \ networksfield.cpp \ passwordfield.cpp \ servicesfield.cpp \ smtphostfield.cpp \ stringfield.cpp POLICY_SOURCES=pagepolicy.cpp \ addressbook_policy.cpp \ administrator_policy.cpp \ distributionlist_policy.cpp \ maintainer_policy.cpp \ service_policy.cpp \ sharedfolder_policy.cpp \ user_policy.cpp FORM_SOURCES=container.cpp dialog.cpp entry.cpp fieldfactory.cpp \ $$DESCRIPTION_SOURCES \ $$FIELD_SOURCES \ $$POLICY_SOURCES LISTING_SOURCES= listingmodel.cpp \ addressbook_listingmodel.cpp \ administrator_listingmodel.cpp \ distributionlist_listingmodel.cpp \ maintainer_listingmodel.cpp \ sharedfolder_listingmodel.cpp \ user_listingmodel.cpp FILTERMODEL_SOURCES = \ addressbook_filtermodel.cpp \ administrator_filtermodel.cpp \ distributionlist_filtermodel.cpp \ maintainer_filtermodel.cpp \ sharedfolder_filtermodel.cpp \ user_filtermodel.cpp PAGE_SOURCES= \ addressbook_page.cpp \ administrator_page.cpp \ distributionlist_page.cpp \ maintainer_page.cpp \ service_page.cpp \ sharedfolder_page.cpp \ user_page.cpp RECORD_SOURCES= \ addressbook_record.cpp \ administrator_record.cpp \ distributionlist_record.cpp \ maintainer_record.cpp \ service_record.cpp \ sharedfolder_record.cpp \ user_record.cpp SOURCES=main.cpp mainwindow.cpp mainwidget.cpp connection.cpp connectiondialog.cpp qldap.cpp \ listingwidget.cpp listingdialog.cpp pagemanager.cpp auth.cpp mainpolicy.cpp itemview.cpp \ ldapsearchdialog.cpp tool.cpp filtermodel.cpp filterwidget.cpp connectioninfomanager.cpp \ crypto.cpp \ $$FILTERMODEL_SOURCES \ $$FORM_SOURCES \ $$LISTING_SOURCES \ $$PAGE_SOURCES \ $$RECORD_SOURCES HEADERS=dialog.h connection.h connectiondialog.h qldap.h listingwidget.h \ listingmodel.h listingdialog.h itemview.h ldapsearchdialog.h \ aclselectionfield.h filtermodel.h filterwidget.h RESOURCES = application.qrc LIBS += -lldap -lssl DEFINES += LDAP_DEPRECATED CONFIG += warn_on qt thread release CONFIG -= debug count( INSTALLDIR, 0 ) { INSTALLDIR = /usr } target.path = $${INSTALLDIR}/bin INSTALLS += target kolabadmin/service_policy.cpp0000644000175000017500000000330710757564565016255 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "service_policy.h" using namespace Form; bool ServicePolicy::fieldEditable( State state, const QString& ) const { if ( state == Add || state == Modify ) { return true; } else return false; } bool ServicePolicy::fieldVisible( State state, const QString &name ) const { if ( state == Modify ) { if ( name == "distributionlists" ) { QString filter( "(&(objectClass=kolabGroupOfNames)(|(cn=hostmaster)(cn=postmaster)(cn=abuse)(cn=virusalert)(cn=MAILER-DAEMON)))" ); QStringList attributes( "dn" ); QLdapResponse response = Connection::self()->search( Connection::self()->baseDn(), QLdap::Sub, filter, attributes ); if ( response.entries().count() < 5 ) return true; else return false; } } return true; } bool ServicePolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/crypto.cpp0000644000175000017500000000211110757564565014546 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "crypto.h" QByteArray Crypto::sha1( const QByteArray &data ) { QByteArray digest( 20, 0 ); SHA1( (unsigned char*)data.data(), data.length(), (unsigned char*)digest.data() ); return digest; } kolabadmin/page.h0000644000175000017500000000267710757564565013630 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PAGE_H #define PAGE_H #include class ListingModel; namespace Form { class Description; class PagePolicy; class Record; } class Page { public: Page() {} virtual ~Page() {} virtual QString name() const = 0; virtual QString title() const = 0; virtual QString description() const = 0; virtual QString iconName() const = 0; virtual bool hasListingMode() const { return true; } virtual ListingModel* model() = 0; virtual Form::Description* formDescription() = 0; virtual Form::PagePolicy* formPolicy() = 0; virtual Form::Record* formRecord() = 0; }; #endif kolabadmin/administrator_description.cpp0000644000175000017500000000362310757564565020522 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "administrator_description.h" using namespace Form; Description::Entry::List AdministratorDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "givenName" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "First Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "sn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Last Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "password" ); entry.setType( "password" ); entry.setLabel( QObject::tr( "Password" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "uid" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Unique Identity (UID)" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } return entries; } kolabadmin/smtphostfield.cpp0000644000175000017500000000374610757564565016132 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include "smtphostfield.h" using namespace Form; SmtpHostField::SmtpHostField( const QString &name, QWidget *parent ) : Field( name, parent ) { mHost = new QLineEdit( this ); QLabel *label = new QLabel( tr( " Port: " ), this ); mPort = new QSpinBox( this ); mPort->setRange( 1, 65536 ); mPort->setValue( 25 ); fieldLayout()->addWidget( mHost, 0, 0 ); fieldLayout()->addWidget( label, 0, 1, Qt::AlignRight ); fieldLayout()->addWidget( mPort, 0, 2 ); } void SmtpHostField::loadEntry( const Entry &entry ) { mHost->setText( entry.value( "postfix-relayhost" ) ); if ( !entry.value( "postfix-relayport" ).isEmpty() ) mPort->setValue( entry.value( "postfix-relayport" ).toInt() ); } void SmtpHostField::saveEntry( Entry &entry ) const { entry.setValue( "postfix-relayhost", mHost->text() ); entry.setValue( "postfix-relayport", QString::number( mPort->value() ) ); } bool SmtpHostField::isValid( QString&, PagePolicy::State ) const { return true; } void SmtpHostField::setEditable( bool editable ) { mHost->setReadOnly( !editable ); mPort->setEnabled( editable ); } kolabadmin/service_page.cpp0000644000175000017500000000367310757564565015700 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "service_description.h" #include "service_policy.h" #include "service_record.h" #include "service_page.h" ServicePage::ServicePage() : mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } ServicePage::~ServicePage() { delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString ServicePage::name() const { return "service"; } QString ServicePage::title() const { return QObject::tr( "Services" ); } QString ServicePage::description() const { return QObject::tr( "Manage Services" ); } QString ServicePage::iconName() const { return "service"; } bool ServicePage::hasListingMode() const { return false; } ListingModel* ServicePage::model() { return 0; } Form::Description* ServicePage::formDescription() { if ( !mDescription ) mDescription = new Form::ServiceDescription; return mDescription; } Form::PagePolicy* ServicePage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::ServicePolicy; return mPolicy; } Form::Record* ServicePage::formRecord() { if ( !mRecord ) mRecord = new Form::ServiceRecord; return mRecord; } kolabadmin/user_policy.cpp0000644000175000017500000000354210757564565015574 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "auth.h" #include "user_policy.h" using namespace Form; bool UserPolicy::fieldEditable( State state, const QString &fieldName ) const { if ( state == Delete ) return false; if ( state == Modify ) { if ( fieldName == "kolabHomeServer" ) return false; else if ( fieldName == "mail" ) return false; if ( Auth::self()->group() == Auth::Users ) { if ( fieldName == "givenName" ) return false; else if ( fieldName == "sn" ) return false; else if ( fieldName == "uid" ) return false; else if ( fieldName == "accttype" ) return false; else if ( fieldName == "alias" ) return false; } } return true; } bool UserPolicy::fieldVisible( State state, const QString &fieldName ) const { if ( state == Modify ) { if ( Auth::self()->group() == Auth::Users ) { if ( fieldName == "cyrus-userquota" ) return false; } } return true; } bool UserPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/sharedfolder_page.cpp0000644000175000017500000000420710757564565016674 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sharedfolder_description.h" #include "sharedfolder_listingmodel.h" #include "sharedfolder_policy.h" #include "sharedfolder_record.h" #include "sharedfolder_page.h" SharedFolderPage::SharedFolderPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } SharedFolderPage::~SharedFolderPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString SharedFolderPage::name() const { return "sharedfolder"; } QString SharedFolderPage::title() const { return QObject::tr( "Shared Folder" ); } QString SharedFolderPage::description() const { return QObject::tr( "Manage shared folders" ); } QString SharedFolderPage::iconName() const { return "sharedfolder"; } ListingModel* SharedFolderPage::model() { if ( !mModel ) mModel = new SharedFolderListingModel; return mModel; } Form::Description* SharedFolderPage::formDescription() { if ( !mDescription ) mDescription = new Form::SharedFolderDescription; return mDescription; } Form::PagePolicy* SharedFolderPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::SharedFolderPolicy; return mPolicy; } Form::Record* SharedFolderPage::formRecord() { if ( !mRecord ) mRecord = new Form::SharedFolderRecord; return mRecord; } kolabadmin/addressbook_record.cpp0000644000175000017500000001306710757564565017100 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "tool.h" #include "addressbook_record.h" using namespace Form; Entry AddressBookRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); return Entry::fromLdapEntry( response.entries().first() ); } bool AddressBookRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QString dnRoot = QString( "cn=external,%1" ).arg( Connection::self()->baseDn() ); QLdapEntry ldapEntry; ldapEntry.addValue( "objectClass", "top" ); ldapEntry.addValue( "objectClass", "inetOrgPerson" ); ldapEntry.addValue( "objectClass", "kolabInetOrgPerson" ); ldapEntry.setValue( "givenName", entry.value( "givenName" ) ); ldapEntry.setValue( "sn", entry.value( "sn" ) ); ldapEntry.setValue( "cn", QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ) ); if ( !entry.value( "title" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "title", entry.value( "title" ) ); if ( !entry.value( "mail" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "mail", entry.value( "mail" ) ); if ( !entry.value( "alias" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "alias", entry.value( "alias" ) ); if ( !entry.value( "o" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "o", entry.value( "o" ) ); if ( !entry.value( "ou" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "ou", entry.value( "ou" ) ); if ( !entry.value( "roomNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "roomNumber", entry.value( "roomNumber" ) ); if ( !entry.value( "street" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "street", entry.value( "street" ) ); if ( !entry.value( "postOfficeBox" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "postOfficeBox", entry.value( "postOfficeBox" ) ); if ( !entry.value( "postalCode" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "postalCode", entry.value( "postalCode" ) ); if ( !entry.value( "l" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "l", entry.value( "l" ) ); if ( !entry.value( "c" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "c", entry.value( "c" ) ); if ( !entry.value( "telephoneNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "telephoneNumber", entry.value( "telephoneNumber" ) ); if ( !entry.value( "facsimileTelephoneNumber" ).isEmpty() || state == PagePolicy::Modify ) ldapEntry.setValue( "facsimileTelephoneNumber", entry.value( "facsimileTelephoneNumber" ) ); if ( state == PagePolicy::Modify ) { QString newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * The 'cn' of the address has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify address '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } if ( !Connection::self()->remove( entry.id() ) ) { errorMsg = QObject::tr( "Could not modify address '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } else { if ( !Connection::self()->modifyAttributes( entry.id(), ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify address '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); if ( !Connection::self()->add( dn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add address '%1': %2" ) .arg( entry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Delete ) { QString ldapError; if ( !Tool::deleteObject( Connection::self(), entry.id(), ldapError, true ) ) { errorMsg = QObject::tr( "Could not delete address '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/maintainer_description.h0000644000175000017500000000206010757564565017430 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_MAINTAINER_DESCRIPTION_H #define FORM_MAINTAINER_DESCRIPTION_H #include "description.h" namespace Form { class MaintainerDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/distributionlist_policy.h0000644000175000017500000000235110757564565017673 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DISTRIBUTIONLIST_POLICY_H #define FORM_DISTRIBUTIONLIST_POLICY_H #include "pagepolicy.h" namespace Form { class DistributionListPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/addressbook_page.h0000644000175000017500000000267310757564565016204 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADDRESSBOOK_PAGE_H #define ADDRESSBOOK_PAGE_H #include "page.h" class AddressBookPage : public Page { public: AddressBookPage(); ~AddressBookPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description* mDescription; Form::PagePolicy* mPolicy; Form::Record *mRecord; }; #endif kolabadmin/mailfilterfield.h0000644000175000017500000000255510757564565016043 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_MAILFILTERFIELD_H #define FORM_MAILFILTERFIELD_H #include "field.h" class QRadioButton; namespace Form { class MailFilterField : public Field { public: MailFilterField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QRadioButton* mForgedHeader; QRadioButton* mNonForgedHeader; }; } #endif kolabadmin/filtermodel.cpp0000644000175000017500000000321710757564565015544 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "filtermodel.h" FilterModel::FilterModel( QObject *parent ) : QAbstractListModel( parent ) { } FilterModel::~FilterModel() { } QString FilterModel::filter( const QModelIndex &index, const QString &userInput, FilterCriterion criterion ) const { if ( !index.isValid() ) return QString(); QString attribute = index.model()->data( index, AttributeRole ).toString(); QString filter; if ( criterion == FilterContains ) filter = QString( "(%1=*%2*)" ).arg( attribute, userInput ); else if ( criterion == FilterEquals ) filter = QString( "(%1=%2)" ).arg( attribute, userInput ); else if ( criterion == FilterStartsWith ) filter = QString( "(%1=%2*)" ).arg( attribute, userInput ); else if ( criterion == FilterEndsWith ) filter = QString( "(%1=*%2)" ).arg( attribute, userInput ); return filter; } kolabadmin/integerfield.h0000644000175000017500000000246010757564565015343 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_INTEGERFIELD_H #define FORM_INTEGERFIELD_H #include "field.h" class QSpinBox; namespace Form { class IntegerField : public Field { public: IntegerField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QSpinBox* mSpinBox; }; } #endif kolabadmin/maintainer_policy.cpp0000644000175000017500000000242210757564565016741 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "maintainer_policy.h" using namespace Form; bool MaintainerPolicy::fieldEditable( State state, const QString &fieldName ) const { if ( state == Delete ) return false; if ( state == Modify ) { if ( fieldName == "uid" ) return false; } return true; } bool MaintainerPolicy::fieldVisible( State, const QString& ) const { return true; } bool MaintainerPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/hostsfield.h0000644000175000017500000000251510757564565015047 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_HOSTSFIELD_H #define FORM_HOSTSFIELD_H #include "field.h" class ItemView; class HostModel; namespace Form { class HostsField : public Field { public: HostsField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView* mView; HostModel* mModel; }; } #endif kolabadmin/mainpolicy.h0000644000175000017500000000171110757564565015044 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINPOLICY_H #define MAINPOLICY_H class MainPolicy { public: bool pageVisible( const QString &name ) const; }; #endif kolabadmin/connectioninfomanager.h0000644000175000017500000000410710757564565017250 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONNECTIONMANAGER_H #define CONNECTIONMANAGER_H #include #include class ConnectionInfo { public: typedef QList List; ConnectionInfo(); ConnectionInfo( const QString &name ); bool isValid() const; QString name() const; void setHost( const QString &host ); QString host() const; void setPort( int port ); int port() const; void setBaseDn( const QString &baseDn ); QString baseDn() const; void setNobodyUser( const QString &nobodyUser ); QString nobodyUser() const; void setNobodyPassword( const QString &nobodyPassword ); QString nobodyPassword() const; private: QString mName; QString mHost; int mPort; QString mBaseDn; QString mNobodyUser; QString mNobodyPassword; }; class ConnectionInfoManager { public: ConnectionInfoManager(); bool contains( const QString &name ) const; ConnectionInfo::List connectionInfos() const; ConnectionInfo connectionInfo( const QString &name ) const; void appendConnectionInfo( const ConnectionInfo &connectionInfo ); void removeConnectionInfo( const QString &name ); void load(); void save(); private: ConnectionInfo::List mConnectionInfos; }; #endif kolabadmin/pagemanager.h0000644000175000017500000000230610757564565015150 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef PAGEMANAGER_H #define PAGEMANAGER_H #include #include #include "page.h" class PageManager { public: ~PageManager(); QStringList pageNames() const; Page* page( const QString &pageName ); static PageManager* self(); private: PageManager(); static PageManager *mSelf; QMap mMap; }; #endif kolabadmin/distributionlist_page.h0000644000175000017500000000272410757564565017314 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DISTRIBUTIONLIST_PAGE_H #define DISTRIBUTIONLIST_PAGE_H #include "page.h" class DistributionListPage : public Page { public: DistributionListPage(); ~DistributionListPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description* mDescription; Form::PagePolicy* mPolicy; Form::Record *mRecord; }; #endif kolabadmin/record.h0000644000175000017500000000224110757564565014155 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_RECORD_H #define FORM_RECORD_H #include "entry.h" #include "pagepolicy.h" namespace Form { class Record { public: virtual ~Record() {}; virtual Entry loadEntry( const QString &id, PagePolicy::State state ) = 0; virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) = 0; }; } #endif kolabadmin/distributionlist_listingmodel.cpp0000644000175000017500000000735310757564565021430 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "distributionlist_filtermodel.h" #include "distributionlist_listingmodel.h" void DistributionListListingModel::doQuery( const QString &userFilter ) { QString filter = QString( "(&(cn=*)%1(objectClass=kolabGroupOfNames))" ).arg( userFilter ); QLdapResponse response = Connection::self()->search( QString(), QLdap::Sub, filter , QStringList(), QLatin1String( "cn" ) ); QString blacklist; blacklist.append( "admin" ); blacklist.append( "maintainer" ); QLdapEntry::List entries = response.entries(); QLdapEntry::List filteredEntries; for ( int i = 0; i < entries.count(); ++i ) { if ( !blacklist.contains( entries[ i ].value( "cn" ) ) ) filteredEntries.append( entries[ i ] ); } mData.setEntries( filteredEntries ); emit layoutChanged(); } int DistributionListListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 2; } int DistributionListListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant DistributionListListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return entry.value( "cn" ); break; case 1: { const QStringList parts = entry.dn().split( "," ); if ( parts.contains( "cn=internal" ) ) return tr( "Internal" ); else return tr( "Public" ); } break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return true; else return false; } else if ( role == ModifyActionLabelRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return tr( "Modify" ); else return tr( "Distribution list deleted, awaiting cleanup..." ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return mData.entries()[ index.row() ].dn(); else return QString(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant DistributionListListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Listname" ); break; case 1: return tr( "Visibility" ); break; default: return QVariant(); } } FilterModel* DistributionListListingModel::filterModel() { return new DistributionListFilterModel( this ); } kolabadmin/addressbook_filtermodel.cpp0000644000175000017500000000327710757564565020132 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_filtermodel.h" AddressBookFilterModel::AddressBookFilterModel( QObject *parent ) : FilterModel( parent ) { } AddressBookFilterModel::~AddressBookFilterModel() { } int AddressBookFilterModel::rowCount( const QModelIndex& ) const { return 2; } QVariant AddressBookFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "Email" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "mail" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/field.h0000644000175000017500000000303210757564565013761 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_FIELD_H #define FORM_FIELD_H #include #include #include "entry.h" #include "pagepolicy.h" namespace Form { class Field : public QWidget { public: Field( const QString &name, QWidget *parent ); QString name() const; QGridLayout* fieldLayout() const; virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); void setDefaultValue( const QString &value ); QString defaultValue() const; private: QString mName; QString mDefaultValue; QGridLayout *mLayout; }; } #endif kolabadmin/itemview.cpp0000644000175000017500000000534010757564565015066 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "itemview.h" ItemView::ItemView( QWidget *parent ) : QWidget( parent ) { QGridLayout *layout = new QGridLayout( this ); layout->setMargin( 0 ); layout->setSpacing( 0 ); mListView = new QListView( this ); layout->addWidget( mListView, 0, 0, 3, 1 ); QToolButton *addButton = new QToolButton( this ); addButton->setFixedSize( 25, 25 ); addButton->setText( "+" ); layout->addWidget( addButton, 0, 1 ); mRemoveButton = new QToolButton( this ); mRemoveButton->setFixedSize( 25, 25 ); mRemoveButton->setText( "-" ); layout->addWidget( mRemoveButton, 1, 1 ); connect( addButton, SIGNAL( clicked() ), this, SLOT( add() ) ); connect( mRemoveButton, SIGNAL( clicked() ), this, SLOT( remove() ) ); setSizePolicy( QSizePolicy::Minimum, QSizePolicy::Minimum ); setMinimumHeight( 150 ); } void ItemView::setModel( QAbstractItemModel *model ) { mListView->setModel( model ); connect( model, SIGNAL( rowsInserted( const QModelIndex&, int, int ) ), this, SLOT( viewUpdated() ) ); connect( model, SIGNAL( rowsRemoved( const QModelIndex&, int, int ) ), this, SLOT( viewUpdated() ) ); connect( model, SIGNAL( dataChanged( const QModelIndex&, const QModelIndex& ) ), this, SLOT( viewUpdated() ) ); connect( model, SIGNAL( layoutChanged() ), this, SLOT( viewUpdated() ) ); viewUpdated(); } QAbstractItemModel *ItemView::model() const { return mListView->model(); } void ItemView::add() { doAdd(); } void ItemView::remove() { QItemSelectionModel *selectionModel = mListView->selectionModel(); const QModelIndex currentIndex = selectionModel->currentIndex(); if ( currentIndex.isValid() ) { mListView->model()->removeRow( currentIndex.row() ); } } void ItemView::viewUpdated() { if ( model()->rowCount() == 0 ) mRemoveButton->setEnabled( false ); else mRemoveButton->setEnabled( true ); } void ItemView::doAdd() { } kolabadmin/maintainer_record.h0000644000175000017500000000222710757564565016370 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_MAINTAINER_RECORD_H #define FORM_MAINTAINER_RECORD_H #include "record.h" namespace Form { class MaintainerRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/sharedfolder_filtermodel.h0000644000175000017500000000236110757564565017732 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SHAREDFOLDER_FILTERMODEL_H #define SHAREDFOLDER_FILTERMODEL_H #include "filtermodel.h" class SharedFolderFilterModel : public FilterModel { public: SharedFolderFilterModel( QObject *parent = 0 ); virtual ~SharedFolderFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/mainwidget.h0000644000175000017500000000222610757564565015032 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINWIDGET_H #define MAINWIDGET_H #include class MainPolicy; class MainWidget : public QTextBrowser { public: MainWidget( QWidget *parent = 0 ); ~MainWidget(); void loadPages(); public Q_SLOTS: virtual void setSource( const QUrl &url ); private: MainPolicy *mPolicy; }; #endif kolabadmin/user_listingmodel.h0000644000175000017500000000263710757564565016440 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef USER_LISTINGMODEL_H #define USER_LISTINGMODEL_H #include "listingmodel.h" class UserListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/filterwidget.h0000644000175000017500000000263310757564565015375 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FILTERWIDGET_H #define FILTERWIDGET_H #include class QComboBox; class QLineEdit; class QSignalMapper; class FilterModel; class FilterWidget : public QWidget { Q_OBJECT public: FilterWidget( FilterModel *model, QWidget *parent = 0 ); virtual ~FilterWidget(); Q_SIGNALS: void filter( const QString &filter ); private Q_SLOTS: void executeUserFilter(); void executeAlphaFilter(); private: FilterModel *mModel; QComboBox *mAttribute; QComboBox *mCriterion; QLineEdit *mUserInput; QSignalMapper *mSignalMapper; }; #endif kolabadmin/sharedfolder_record.cpp0000644000175000017500000000735310757564565017243 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "tool.h" #include "sharedfolder_record.h" using namespace Form; Entry SharedFolderRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); return Entry::fromLdapEntry( response.entries().first() ); } bool SharedFolderRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QString dnRoot = Connection::self()->baseDn(); QLdapEntry ldapEntry; ldapEntry.addValue( "objectClass", "kolabSharedFolder" ); ldapEntry.setValue( "cn", entry.value( "cn" ).toLower() ); ldapEntry.setValue( "kolabHomeServer", entry.value( "kolabHomeServer" ) ); ldapEntry.setValue( "cyrus-userquota", entry.value( "cyrus-userquota" ) ); QStringList acls = entry.values( "acl" ); for ( int i = 0; i < acls.count(); ++i ) ldapEntry.addValue( "acl", acls[ i ] ); if ( state == PagePolicy::Modify ) { QString newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * The 'cn' of the shared folder has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify shared folder '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } if ( !Connection::self()->remove( entry.id() ) ) { errorMsg = QObject::tr( "Could not modify shared folder '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } else { if ( !Connection::self()->modifyAttributes( entry.id(), ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify shared folder '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); if ( !Connection::self()->add( dn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add shared folder '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Delete ) { QString ldapError; if ( !Tool::deleteSharedFolder( Connection::self(), entry.id(), ldapError ) ) { errorMsg = QObject::tr( "Could not delete shared folder '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/sharedfolder_page.h0000644000175000017500000000270010757564565016335 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SHAREDFOLDER_PAGE_H #define SHAREDFOLDER_PAGE_H #include "page.h" class SharedFolderPage : public Page { public: SharedFolderPage(); ~SharedFolderPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description *mDescription; Form::PagePolicy *mPolicy; Form::Record *mRecord; }; #endif kolabadmin/addressbook_record.h0000644000175000017500000000223210757564565016535 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADDRESSBOOK_RECORD_H #define FORM_ADDRESSBOOK_RECORD_H #include "record.h" namespace Form { class AddressBookRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/sharedfolder_description.cpp0000644000175000017500000000360510757564565020304 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sharedfolder_description.h" using namespace Form; Description::Entry::List SharedFolderDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "cn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Folder Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabHomeServer" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Folder Location" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } { Entry entry; entry.setName( "cyrus-userquota" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Quota Limit" ) ); entry.setComment( QObject::tr( "MBytes (empty for unlimited)" ) ); entries.append( entry ); } { Entry entry; entry.setName( "acls" ); entry.setType( "aclselection" ); entry.setLabel( QObject::tr( "Permission for UID/GID" ) ); entries.append( entry ); } return entries; } kolabadmin/pagemanager.cpp0000644000175000017500000000464510757564565015513 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_page.h" #include "administrator_page.h" #include "distributionlist_page.h" #include "maintainer_page.h" #include "service_page.h" #include "sharedfolder_page.h" #include "user_page.h" #include "pagemanager.h" PageManager* PageManager::mSelf = 0; PageManager::PageManager() { } PageManager::~PageManager() { qDeleteAll( mMap ); } QStringList PageManager::pageNames() const { static QStringList list; if ( list.isEmpty() ) { list.append( "user" ); list.append( "addressbook" ); list.append( "sharedfolder" ); list.append( "distributionlist" ); list.append( "administrator" ); list.append( "maintainer" ); list.append( "service" ); } return list; } Page* PageManager::page( const QString &pageName ) { if ( !mMap.contains( pageName ) ) { Page *page = 0; if ( pageName == "addressbook" ) { page = new AddressBookPage; } else if ( pageName == "administrator" ) { page = new AdministratorPage; } else if ( pageName == "distributionlist" ) { page = new DistributionListPage; } else if ( pageName == "maintainer" ) { page = new MaintainerPage; } else if ( pageName == "service" ) { page = new ServicePage; } else if ( pageName == "sharedfolder" ) { page = new SharedFolderPage; } else if ( pageName == "user" ) { page = new UserPage; } if ( page ) { mMap.insert( pageName, page ); return page; } else { return 0; } } else { return mMap[ pageName ]; } } PageManager* PageManager::self() { if ( !mSelf ) mSelf = new PageManager(); return mSelf; } kolabadmin/distributionlist_page.cpp0000644000175000017500000000435410757564565017650 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "distributionlist_description.h" #include "distributionlist_listingmodel.h" #include "distributionlist_policy.h" #include "distributionlist_record.h" #include "distributionlist_page.h" DistributionListPage::DistributionListPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } DistributionListPage::~DistributionListPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString DistributionListPage::name() const { return "distributionlist"; } QString DistributionListPage::title() const { return QObject::tr( "Distribution Lists" ); } QString DistributionListPage::description() const { return QObject::tr( "Manage distribution lists" ); } QString DistributionListPage::iconName() const { return "distributionlist"; } ListingModel* DistributionListPage::model() { if ( !mModel ) mModel = new DistributionListListingModel; return mModel; } Form::Description* DistributionListPage::formDescription() { if ( !mDescription ) mDescription = new Form::DistributionListDescription; return mDescription; } Form::PagePolicy* DistributionListPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::DistributionListPolicy; return mPolicy; } Form::Record* DistributionListPage::formRecord() { if ( !mRecord ) mRecord = new Form::DistributionListRecord; return mRecord; } kolabadmin/user_filtermodel.h0000644000175000017500000000231110757564565016241 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef USER_FILTERMODEL_H #define USER_FILTERMODEL_H #include "filtermodel.h" class UserFilterModel : public FilterModel { public: UserFilterModel( QObject *parent = 0 ); virtual ~UserFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/aclselectionfield.cpp0000644000175000017500000002241410757564565016707 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include "connection.h" #include "itemview.h" #include "ldapsearchdialog.h" #include "aclselectionfield.h" using namespace Form; /** * An acl can have the following form where xxx is the uid and yyy the right: * * xxx yyy * xxx yyy yyy * xxx xxx yyy * xxx xxx yyy yyy * group:xxx yyy * group:xxx yyy yyy * group:xxx xxx yyy yyy * * so a simple split( ' ' ) doesn't work here... */ static QStringList splitAcl( const QString &acl ) { QStringList retval; QStringList aclParts = acl.split( " " ); if ( aclParts.count() == 2 ) { retval.append( aclParts[ 0 ] ); retval.append( aclParts[ 1 ] ); } else if ( aclParts.count() >= 3 ) { if ( aclParts[ aclParts.count() - 2 ] == "read" ) { // yyy yyy QStringList uidParts; for ( int i = 0; i < (aclParts.count() - 2); ++i ) uidParts.append( aclParts[ i ] ); retval.append( uidParts.join( " " ) ); retval.append( QString( "%1 %2" ).arg( aclParts[ aclParts.count() - 2 ], aclParts[ aclParts.count() - 1 ] ) ); } else { QStringList uidParts; for ( int i = 0; i < (aclParts.count() - 1); ++i ) uidParts.append( aclParts[ i ] ); retval.append( uidParts.join( " " ) ); retval.append( aclParts[ aclParts.count() - 1 ] ); } } return retval; } class AclModel : public QAbstractListModel { public: AclModel( QObject *parent = 0 ) : QAbstractListModel( parent ) { } virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const { return 1; } virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const { return mList.count(); } virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) return mList[ index.row() ].displayName; else if ( role == Qt::UserRole ) return mList[ index.row() ].acl; else return QVariant(); } virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) { if ( !index.isValid() ) { return false; } if ( !value.isValid() ) return false; if ( role == Qt::UserRole ) { QStringList acl = value.toStringList(); mList[ index.row() ].acl = acl; QString displayName; if ( acl[ 0 ].startsWith( "group:" ) ) displayName = tr( "Group: %1 (%2)" ).arg( acl[ 0 ].mid( 6 ), acl[ 1 ] ); else displayName = tr( "Person: %1 (%2)" ).arg( acl[ 0 ], acl[ 1 ] ); mList[ index.row() ].displayName = displayName; } return true; } virtual bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginInsertRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.insert( row, Entry() ); endInsertRows(); return true; } virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginRemoveRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.removeAt( row ); endRemoveRows(); return true; } private: class Entry { public: QString displayName; QStringList acl; }; QList mList; }; class AclItemView : public ItemView { public: AclItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { AclDialog dlg( this ); if ( dlg.exec() ) { QStringList acl = dlg.acl(); QAbstractItemModel *model = mListView->model(); int count = model->rowCount(); bool found = false; for ( int i = 0; i < count; ++i ) { QStringList modelAcl = model->data( model->index( i, 0 ), Qt::UserRole ).toStringList(); if ( acl[ 0 ] == modelAcl[ 0 ] && acl[ 1 ] == modelAcl[ 1 ] ) { found = true; break; } } if ( !found ) { model->insertRow( count ); model->setData( model->index( count, 0 ), acl, Qt::UserRole ); } } } }; AclSelectionField::AclSelectionField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new AclItemView( this ); mModel = new AclModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void AclSelectionField::loadEntry( const Entry &entry ) { QStringList acls = entry.values( "acl" ); for ( int i = 0; i < acls.count(); ++i ) { QStringList modelAcl = splitAcl( acls[ i ] ); mModel->insertRow( i ); mModel->setData( mModel->index( i, 0 ), modelAcl, Qt::UserRole ); } } void AclSelectionField::saveEntry( Entry &entry ) const { entry.clearValue( "acl" ); for ( int i = 0; i < mModel->rowCount(); ++i ) { QStringList acl = mModel->data( mModel->index( i, 0 ), Qt::UserRole ).toStringList(); entry.addValue( "acl", QString( "%1 %2" ).arg( acl[ 0 ], acl[ 1 ] ) ); } } bool AclSelectionField::isValid( QString&, PagePolicy::State ) const { return true; } void AclSelectionField::setEditable( bool editable ) { mView->setEnabled( editable ); } AclDialog::AclDialog( QWidget *parent ) : QDialog( parent ) { QGridLayout *layout = new QGridLayout( this ); QLabel *label = new QLabel( tr( "User/Group:" ), this ); layout->addWidget( label, 0, 0 ); mUidLabel = new QLineEdit( this ); mUidLabel->setReadOnly( true ); layout->addWidget( mUidLabel, 0, 1, 1, 2 ); QToolButton *toolButton = new QToolButton( this ); toolButton->setText( "..." ); connect( toolButton, SIGNAL( clicked() ), this, SLOT( selectUid() ) ); layout->addWidget( toolButton, 0, 3 ); label = new QLabel( tr( "Rights:" ), this ); layout->addWidget( label, 1, 0 ); mRights = new QComboBox( this ); layout->addWidget( mRights, 1, 1, 1, 3 ); mRights->addItem( tr( "none" ) ); mRights->addItem( tr( "post" ) ); mRights->addItem( tr( "read" ) ); mRights->addItem( tr( "read/post" ) ); mRights->addItem( tr( "append" ) ); mRights->addItem( tr( "write" ) ); mRights->addItem( tr( "read anon" ) ); mRights->addItem( tr( "read anon/post" ) ); mRights->addItem( tr( "read hidden" ) ); mRights->addItem( tr( "read hidden/post" ) ); mRights->addItem( tr( "all" ) ); QPushButton *button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 2, 2 ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 2, 3 ); } QStringList AclDialog::acl() const { QStringList rights; rights.append( "none" ); rights.append( "post" ); rights.append( "read" ); rights.append( "read/post" ); rights.append( "append" ); rights.append( "write" ); rights.append( "read anon" ); rights.append( "read anon/post" ); rights.append( "read hidden" ); rights.append( "read hidden/post" ); rights.append( "all" ); QStringList acl; acl.append( mUid ); acl.append( rights[ mRights->currentIndex() ] ); return acl; } void AclDialog::selectUid() { QStringList blacklist; blacklist << QString( "cn=manager,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=calendar,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=nobody,cn=internal,%1" ).arg( Connection::self()->baseDn() ); LdapSearchDialog dlg( Connection::self(), this ); dlg.setSearchFilter( "(|(&(objectClass=kolabInetOrgPerson)(|(uid=*%i*)(alias=*%i*)(mail=*%i*)))(&(objectClass=kolabGroupOfNames)(cn=*%i*)))" ); dlg.setDisplayFormat( "%cn% (%mail%)" ); dlg.setBlackList( blacklist ); if ( dlg.exec() ) { const QLdapEntry::List entries = dlg.selectedEntries(); if ( entries.isEmpty() ) return; const QLdapEntry entry = entries.first(); mUidLabel->setText( entry.value( "cn" ) ); if ( entry.values( "objectClass" ).contains( "kolabInetOrgPerson" ) ) { mUid = entry.value( "mail" ); } else { mUid = QString( "group:%1" ).arg( entry.value( "cn" ) ); } } } void AclDialog::accept() { if ( mUid.isEmpty() ) { QMessageBox::warning( this, tr( "Invalid Input" ), tr( "You have to select an user or group!" ) ); return; } done( Accepted ); } kolabadmin/filtermodel.h0000644000175000017500000000257710757564565015221 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FILTERMODEL_H #define FILTERMODEL_H #include class FilterModel : public QAbstractListModel { Q_OBJECT public: enum FilterRole { AttributeRole = Qt::UserRole + 1, MainAttributeRole }; enum FilterCriterion { FilterContains, FilterEquals, FilterStartsWith, FilterEndsWith }; FilterModel( QObject *parent = 0 ); virtual ~FilterModel(); virtual QString filter( const QModelIndex &index, const QString &userInput, FilterCriterion criterion ) const; }; #endif kolabadmin/maintainer_policy.h0000644000175000017500000000232710757564565016412 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_MAINTAINER_POLICY_H #define FORM_MAINTAINER_POLICY_H #include "pagepolicy.h" namespace Form { class MaintainerPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/maintainer_filtermodel.cpp0000644000175000017500000000326510757564565017756 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "maintainer_filtermodel.h" MaintainerFilterModel::MaintainerFilterModel( QObject *parent ) : FilterModel( parent ) { } MaintainerFilterModel::~MaintainerFilterModel() { } int MaintainerFilterModel::rowCount( const QModelIndex& ) const { return 2; } QVariant MaintainerFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "UID" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "uid" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/administrator_record.cpp0000644000175000017500000001535210757564566017460 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "crypto.h" #include "tool.h" #include "administrator_record.h" using namespace Form; Entry AdministratorRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); Entry entry = Entry::fromLdapEntry( response.entries().first() ); if ( entry.value( "givenName" ).isEmpty() ) { const QString cn = entry.value( "cn" ); const QString sn = entry.value( "sn" ); const QString givenName = cn.left( cn.length() - sn.length() ).trimmed(); entry.setValue( "givenName", givenName ); } return entry; } bool AdministratorRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QString dnRoot = QString( "cn=internal,%1" ).arg( Connection::self()->baseDn() ); QLdapEntry ldapEntry; ldapEntry.addValue( "objectClass", "top" ); ldapEntry.addValue( "objectClass", "inetOrgPerson" ); ldapEntry.addValue( "objectClass", "kolabInetOrgPerson" ); ldapEntry.setValue( "givenName", entry.value( "givenName" ) ); ldapEntry.setValue( "sn", entry.value( "sn" ) ); ldapEntry.setValue( "cn", QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ) ); if ( !entry.value( "password" ).isEmpty() ) { QByteArray data = "{sha}" + Crypto::sha1( entry.value( "password" ).toUtf8() ).toBase64(); ldapEntry.setValue( "userPassword", QString::fromUtf8( data ) ); } else { ldapEntry.setValue( "userPassword", entry.value( "userPassword" ) ); } ldapEntry.setValue( "uid", entry.value( "uid" ).toLower() ); if ( state == PagePolicy::Modify ) { QString newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * The 'cn' of the administrator has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { /** * Add the object under the new dn... */ if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... and remove the object under the old dn. */ if ( !Connection::self()->remove( entry.id() ) ) { errorMsg = QObject::tr( "Could not modify administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * Add the new administrator dn to the admin group... */ QString adminGroupDn = QString( "cn=admin,%1" ).arg( dnRoot ); QLdapEntry memberEntry; memberEntry.setValue( "member", newDn ); if ( !Connection::self()->addAttributes( adminGroupDn, memberEntry ) ) { errorMsg = QObject::tr( "Could not modify administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... and remove the old administrator dn from the admin group. */ memberEntry.setValue( "member", entry.id() ); if ( !Connection::self()->removeAttributes( adminGroupDn, memberEntry ) ) { errorMsg = QObject::tr( "Could not modify administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } else { if ( !Connection::self()->modifyAttributes( entry.id(), ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * First add the administrator... */ if ( !Connection::self()->add( dn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add administrator '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } /** * ... then add the administrator dn to the admin group. */ QLdapEntry memberEntry; memberEntry.setDn( QString( "cn=admin,cn=internal,%1" ).arg( Connection::self()->baseDn() ) ); memberEntry.setValue( "member", dn ); if ( !Connection::self()->addAttributes( memberEntry.dn(), memberEntry ) ) { errorMsg = QObject::tr( "Could not add administrator '%1' to group '%2': %3" ) .arg( entry.value( "cn" ), memberEntry.dn(), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Delete ) { /** * First remove administrator dn from admin group... */ QLdapEntry memberEntry; memberEntry.setDn( QString( "cn=admin,cn=internal,%1" ).arg( Connection::self()->baseDn() ) ); memberEntry.setValue( "member", entry.id() ); if ( !Connection::self()->removeAttributes( memberEntry.dn(), memberEntry ) ) { errorMsg = QObject::tr( "Could not remove administrator '%1' from group '%2': %3" ) .arg( entry.value( "cn" ), memberEntry.dn(), Connection::self()->errorString() ); return false; } /** * ... then remove the administrator itself. */ QString ldapError; if ( !Tool::deleteObject( Connection::self(), entry.id(), ldapError ) ) { errorMsg = QObject::tr( "Could not remove administrator '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/distributionlist_description.cpp0000644000175000017500000000324710757564566021260 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "distributionlist_description.h" using namespace Form; Description::Entry::List DistributionListDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "cn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "List Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "members" ); entry.setType( "memberselection" ); entry.setLabel( QObject::tr( "Members" ) ); entries.append( entry ); } { Entry entry; entry.setName( "hidden" ); entry.setType( "boolean" ); entry.setLabel( QObject::tr( "Hidden" ) ); entry.setComment( QObject::tr( "Check here to make this distribution list available only to authenticated users" ) ); entries.append( entry ); } return entries; } kolabadmin/user_description.cpp0000644000175000017500000001341310757564566016617 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "user_description.h" using namespace Form; Description::Entry::List UserDescription::entries() const { Entry::List entries; { Entry entry; entry.setName( "givenName" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "First Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "sn" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Last Name" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "password" ); entry.setType( "password" ); entry.setLabel( QObject::tr( "Password" ) ); entry.setComment( QObject::tr( "Required" ) ); entries.append( entry ); } { Entry entry; entry.setName( "mail" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Primary Email Address" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } { Entry entry; entry.setName( "uid" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Unique Identity (UID)" ) ); entry.setComment( QObject::tr( "Optional - Defaults to Primary Email Address" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabHomeServer" ); entry.setType( "non-empty-string" ); entry.setLabel( QObject::tr( "Mailbox Home Server" ) ); entry.setComment( QObject::tr( "Required, non volatile" ) ); entries.append( entry ); } { Entry entry; entry.setName( "accttype" ); entry.setType( "accounttype" ); entry.setLabel( QObject::tr( "Account Type" ) ); entry.setComment( QObject::tr( "NOTE: An internal user is a user that will not be visible in the address book" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabInvitationPolicy" ); entry.setType( "invitationpolicy" ); entry.setLabel( QObject::tr( "Invitation Policy" ) ); entry.setComment( QObject::tr( "For automatic invitation handling" ) + "\n" + QObject::tr( "NOTE: For regular accounts to use this feature, give the \'calendar\' user access to the Calendar folder" ) ); entries.append( entry ); } { Entry entry; entry.setName( "title" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Title" ) ); entries.append( entry ); } { Entry entry; entry.setName( "alias" ); entry.setType( "alias" ); entry.setLabel( QObject::tr( "Email Aliases" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabDelegate" ); entry.setType( "delegate" ); entry.setLabel( QObject::tr( "Delegates" ) ); entries.append( entry ); } { Entry entry; entry.setName( "o" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Organisation" ) ); entries.append( entry ); } { Entry entry; entry.setName( "ou" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Organisational Unit" ) ); entries.append( entry ); } { Entry entry; entry.setName( "roomNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Room Number" ) ); entries.append( entry ); } { Entry entry; entry.setName( "street" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Street Address" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postOfficeBox" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Postbox" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postalCode" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Postal Code" ) ); entries.append( entry ); } { Entry entry; entry.setName( "l" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "City" ) ); entries.append( entry ); } { Entry entry; entry.setName( "c" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Country" ) ); entries.append( entry ); } { Entry entry; entry.setName( "telephoneNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Telephone Number" ) ); entries.append( entry ); } { Entry entry; entry.setName( "facsimileTelephoneNumber" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Fax Number" ) ); entries.append( entry ); } { Entry entry; entry.setName( "cyrus-userquota" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "User Quota in MBytes" ) ); entry.setComment( QObject::tr( "Leave blank for umlimited" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabFreeBusyFuture" ); entry.setType( "string" ); entry.setLabel( QObject::tr( "Free/Busy interval in days" ) ); entry.setComment( QObject::tr( "Leave blank for default (60 days)" ) ); entries.append( entry ); } return entries; } kolabadmin/administrator_page.h0000644000175000017500000000270510757564566016561 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADMINISTRATOR_PAGE_H #define ADMINISTRATOR_PAGE_H #include "page.h" class AdministratorPage : public Page { public: AdministratorPage(); ~AdministratorPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description *mDescription; Form::PagePolicy *mPolicy; Form::Record *mRecord; }; #endif kolabadmin/field.cpp0000644000175000017500000000276410757564566014330 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "field.h" using namespace Form; Field::Field( const QString &name, QWidget *parent ) : QWidget( parent ), mName( name ) { mLayout = new QGridLayout( this ); mLayout->setMargin( 0 ); mLayout->setSpacing( 0 ); } QString Field::name() const { return mName; } QGridLayout* Field::fieldLayout() const { return mLayout; } void Field::loadEntry( const Entry& ) { } void Field::saveEntry( Entry& ) const { } bool Field::isValid( QString&, PagePolicy::State ) const { return false; } void Field::setEditable( bool ) { } void Field::setDefaultValue( const QString &value ) { mDefaultValue = value; } QString Field::defaultValue() const { return mDefaultValue; } kolabadmin/connectiondialog.h0000644000175000017500000000420110757564566016215 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONNECTIONDIALOG_H #define CONNECTIONDIALOG_H #include #include "connectioninfomanager.h" class QComboBox; class QLineEdit; class QListWidget; class QPushButton; class QSpinBox; class ConnectionDialog : public QDialog { Q_OBJECT public: ConnectionDialog( QWidget *parent = 0 ); public Q_SLOTS: virtual void accept(); void configure(); private: void updateButtonState(); void updateConnectionBox(); QComboBox *mConnection; QLineEdit *mUser; QLineEdit *mPassword; QPushButton *mOkButton; ConnectionInfoManager mConnectionInfoManager; }; class ConfigureDialog : public QDialog { Q_OBJECT public: ConfigureDialog( ConnectionInfoManager *manager, QWidget *parent = 0 ); private Q_SLOTS: void add(); void edit(); void remove(); private: QListWidget *mWidget; ConnectionInfoManager *mManager; }; class ConnectionInfoDialog : public QDialog { Q_OBJECT public: ConnectionInfoDialog( QWidget *parent = 0 ); void setConnectionInfo( const ConnectionInfo &connectionInfo ); ConnectionInfo connectionInfo() const; public Q_SLOTS: virtual void accept(); private: QLineEdit *mName; QLineEdit *mHost; QSpinBox *mPort; QLineEdit *mBaseDn; QLineEdit *mUser; QLineEdit *mPassword; }; #endif kolabadmin/addressbook_policy.h0000644000175000017500000000233210757564566016560 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADDRESSBOOK_POLICY_H #define FORM_ADDRESSBOOK_POLICY_H #include "pagepolicy.h" namespace Form { class AddressBookPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/maintainer_page.h0000644000175000017500000000266610757564566016036 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINTAINER_PAGE_H #define MAINTAINER_PAGE_H #include "page.h" class MaintainerPage : public Page { public: MaintainerPage(); ~MaintainerPage(); virtual QString name() const; virtual QString title() const; virtual QString description() const; virtual QString iconName() const; virtual ListingModel* model(); virtual Form::Description* formDescription(); virtual Form::PagePolicy* formPolicy(); virtual Form::Record* formRecord(); private: ListingModel *mModel; Form::Description *mDescription; Form::PagePolicy *mPolicy; Form::Record *mRecord; }; #endif kolabadmin/booleanfield.h0000644000175000017500000000246310757564566015331 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_BOOLEANFIELD_H #define FORM_BOOLEANFIELD_H #include "field.h" class QCheckBox; namespace Form { class BooleanField : public Field { public: BooleanField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QCheckBox* mCheckBox; }; } #endif kolabadmin/listingmodel.cpp0000644000175000017500000000204110757564566015723 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "listingmodel.h" ListingModel::ListingModel( QObject *parent ) : QAbstractTableModel( parent ) { } ListingModel::~ListingModel() { } void ListingModel::query( const QString &filter ) { doQuery( filter ); } kolabadmin/addressbook_filtermodel.h0000644000175000017500000000235410757564566017573 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADDRESSBOOK_FILTERMODEL_H #define ADDRESSBOOK_FILTERMODEL_H #include "filtermodel.h" class AddressBookFilterModel : public FilterModel { public: AddressBookFilterModel( QObject *parent = 0 ); virtual ~AddressBookFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/pagepolicy.cpp0000644000175000017500000000236210757564566015373 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "pagepolicy.h" using namespace Form; PagePolicy::PagePolicy() { } PagePolicy::~PagePolicy() { } bool PagePolicy::fieldEditable( State state, const QString& ) const { if ( state == Add || state == Modify ) return true; else return false; } bool PagePolicy::fieldVisible( State, const QString& ) const { return true; } bool PagePolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/listingdialog.h0000644000175000017500000000234610757564566015537 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LISTINGDIALOG_H #define LISTINGDIALOG_H #include #include "page.h" class ListingModel; class ListingDialog : public QDialog { Q_OBJECT public: ListingDialog( Page *page, QWidget *parent ); private Q_SLOTS: void addEntry(); void modifyEntry( const QString &id ); void deleteEntry( const QString &id ); private: Page* mPage; ListingModel* mModel; }; #endif kolabadmin/qldap.cpp0000644000175000017500000002646710757564566014354 0ustar tobiastobias/* Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "qldap.h" #include #include #include #define LDAP_FULL_ADD 0xff class QLdap::Private { public: Private() : handle( 0 ), port( 389 ), errorCode( 0 ) { } LDAP *handle; QString hostName; quint16 port; QString baseDn; QString user; QString password; int errorCode; }; QLdap::QLdap( QObject *parent ) : QObject( parent ), d( new Private() ) { } QLdap::QLdap( const QString &hostName, quint16 port, QObject *parent ) : QObject( parent ), d( new Private() ) { d->hostName = hostName; d->port = port; } QLdap::~QLdap() { delete d; d = 0; } void QLdap::setHost( const QString &hostName ) { d->hostName = hostName; } QString QLdap::host() const { return d->hostName; } void QLdap::setPort( int port ) { d->port = port; } int QLdap::port() const { return d->port; } void QLdap::setUser( const QString &user ) { d->user = user; } QString QLdap::user() const { return d->user; } void QLdap::setPassword( const QString &password ) { d->password = password; } QString QLdap::password() const { return d->password; } void QLdap::setBaseDn( const QString &baseDn ) { d->baseDn = baseDn; } QString QLdap::baseDn() const { return d->baseDn; } QLdapResponse QLdap::search( const QString &base, Scope scope, const QString &filter, const QStringList &attributes, const QString &sortBy ) { QLdapResponse response; bool ok = connect(); if ( !ok ) return response; int ldapScope = LDAP_SCOPE_BASE; if ( scope == Base ) ldapScope = LDAP_SCOPE_BASE; else if ( scope == OneLevel ) ldapScope = LDAP_SCOPE_ONELEVEL; else if ( scope == Sub ) ldapScope = LDAP_SCOPE_SUBTREE; // copy attributes in query structures char **attrs = 0; if ( !attributes.isEmpty() ) { attrs = ( char** )malloc( sizeof(char*) * (attributes.count() + 1) ); int i; for ( i = 0; i < attributes.count(); ++i ) { QByteArray data = attributes[ i ].toUtf8(); int length = data.length() + 1; attrs[ i ] = ( char* )malloc( length ); memset( attrs[ i ], 0, length ); memcpy( attrs[ i ], data.data(), length - 1 ); } attrs[ attributes.count() ] = 0; } LDAPMessage *res; int result = ldap_search_s( d->handle, base.toUtf8(), ldapScope, filter.toUtf8(), attrs, 0, &res ); if ( result != LDAP_SUCCESS ) { d->errorCode = result; } else { LDAPMessage *entry = 0; char *attr = 0; if ( !sortBy.isEmpty() ) ldap_sort_entries( d->handle, &res, sortBy.toUtf8(), strcasecmp ); QLdapEntry::List ldapEntries; for ( entry = ldap_first_entry( d->handle, res ); entry != 0; entry = ldap_next_entry( d->handle, entry ) ) { QLdapEntry ldapEntry; char *dn = ldap_get_dn( d->handle, entry ); ldapEntry.setDn( QString::fromUtf8( dn ) ); ldap_memfree( dn ); BerElement *ber = 0; for ( attr = ldap_first_attribute( d->handle, entry, &ber ); attr != 0; attr = ldap_next_attribute( d->handle, entry, ber ) ) { char **vals = ldap_get_values( d->handle, entry, attr ); if ( vals == 0 ) continue; int valueCount = ldap_count_values( vals ); for ( int i = 0; i < valueCount; ++i ) { ldapEntry.addValue( QString::fromUtf8( attr ), QString::fromUtf8( vals[ i ] ) ); } ldap_value_free(vals); vals = 0; ldap_memfree(attr); attr = 0; } ldapEntries.append( ldapEntry ); } response.setEntries( ldapEntries ); } // free query structures for ( int i = 0; i < attributes.count(); ++i ) free( attrs[ i ] ); free( attrs ); disconnect(); return response; } bool QLdap::add( const QString &dn, const QLdapEntry &entry ) { bool ok = connect(); if ( !ok ) return false; ok = ok && change( dn, entry, LDAP_FULL_ADD ); ok = ok && disconnect(); return ok; } bool QLdap::addAttributes( const QString &dn, const QLdapEntry &entry ) { bool ok = connect(); if ( !ok ) return false; ok = ok && change( dn, entry, LDAP_MOD_ADD ); ok = ok && disconnect(); return ok; } bool QLdap::modifyAttributes( const QString &dn, const QLdapEntry &entry ) { bool ok = connect(); if ( !ok ) return false; ok = ok && change( dn, entry, LDAP_MOD_REPLACE ); ok = ok && disconnect(); return ok; } bool QLdap::removeAttributes( const QString &dn, const QLdapEntry &entry ) { bool ok = connect(); if ( !ok ) return false; ok = ok && change( dn, entry, LDAP_MOD_DELETE ); ok = ok && disconnect(); return ok; } bool QLdap::remove( const QString &dn ) { bool ok = connect(); if ( !ok ) return false; int result = ldap_delete_s( d->handle, dn.toUtf8().data() ); if ( result != LDAP_SUCCESS ) { d->errorCode = result; disconnect(); return false; } ok = ok && disconnect(); return ok; } bool QLdap::rename( const QString &dn, const QString &newDn, const QString &baseDn, bool deleteOld ) { bool ok = connect(); if ( !ok ) return false; int result = ldap_rename_s( d->handle, dn.toUtf8().data(), newDn.toUtf8().data(), baseDn.toUtf8().data(), ( deleteOld ? 1 : 0 ), 0, 0 ); if ( result != LDAP_SUCCESS ) { d->errorCode = result; disconnect(); return false; } ok = ok && disconnect(); return ok; } bool QLdap::change( const QString &dn, const QLdapEntry &entry, int operation ) { LDAPMod **ldap_mods; int size = (entry.attributeNames().count()+1) * sizeof(LDAPMod*); ldap_mods = (LDAPMod**)malloc(size); memset(ldap_mods, 0, size); bool fullAdd = false; if ( operation == LDAP_FULL_ADD ) { operation = LDAP_MOD_ADD; fullAdd = true; } for ( int i = 0; i < entry.attributeNames().count(); ++i ) { ldap_mods[ i ] = (LDAPMod*)malloc( sizeof( LDAPMod ) ); ldap_mods[ i ]->mod_type = strdup( entry.attributeNames()[ i ].toUtf8().data() ); ldap_mods[ i ]->mod_op = operation | LDAP_MOD_BVALUES; QStringList values = entry.values( entry.attributeNames()[ i ] ); if ( values.isEmpty() ) { ldap_mods[ i ]->mod_bvalues = 0; } else { int size = (values.count() + 1) * sizeof( struct berval* ); ldap_mods[ i ]->mod_bvalues = (struct berval**)malloc( size ); memset(ldap_mods[ i ]->mod_bvalues, 0, size ); for ( int j = 0; j < values.count(); ++j ) { ldap_mods[ i ]->mod_bvalues[ j ] = (struct berval*)malloc( sizeof( struct berval ) ); ldap_mods[ i ]->mod_bvalues[ j ]->bv_len = values[ j ].toUtf8().length(); ldap_mods[ i ]->mod_bvalues[ j ]->bv_val = strdup( values[ j ].toUtf8().data() ); qDebug( "%s: %s (%d)", qPrintable( entry.attributeNames()[ i ] ), ldap_mods[ i ]->mod_bvalues[ j ]->bv_val, (int)ldap_mods[ i ]->mod_bvalues[ j ]->bv_len ); } ldap_mods[ i ]->mod_bvalues[ values.count() ] = 0; } } ldap_mods[ entry.attributeNames().count() ] = 0; int result = 0; if ( fullAdd ) result = ldap_add_s( d->handle, dn.toUtf8().data(), ldap_mods ); else result = ldap_modify_s( d->handle, dn.toUtf8().data(), ldap_mods ); if ( result != LDAP_SUCCESS ) d->errorCode = result; for ( int i = 0; i < entry.attributeNames().count(); ++i ) { free( ldap_mods[ i ]->mod_type ); QStringList values = entry.values( entry.attributeNames()[ i ] ); if ( !values.isEmpty() ) { for ( int j = 0; j < values.count(); ++j ) { free( ldap_mods[ i ]->mod_bvalues[ j ]->bv_val ); free( ldap_mods[ i ]->mod_bvalues[ j ] ); } free( ldap_mods[ i ]->mod_bvalues ); } free( ldap_mods[ i ] ); } free( ldap_mods ); return ( result == LDAP_SUCCESS ); } QString QLdap::errorString() const { return QString::fromUtf8( ldap_err2string( d->errorCode ) ); } bool QLdap::connect() { if ( d->handle != 0 ) return true; d->handle = ldap_open( d->hostName.toUtf8(), d->port ); if ( d->handle == 0 ) { d->errorCode = errno; return false; } int version = 3; ldap_set_option( d->handle, LDAP_OPT_PROTOCOL_VERSION, &version ); bool ok = bind(); return ok; } bool QLdap::bind() { int result = ldap_simple_bind_s( d->handle, d->user.toUtf8(), d->password.toUtf8() ); if ( result != LDAP_SUCCESS ) { d->errorCode = result; return false; } return true; } bool QLdap::unbind() { if ( d->handle == 0 ) return false; int result = ldap_unbind_s( d->handle ); if ( result != LDAP_SUCCESS ) { d->errorCode = result; return false; } return true; } bool QLdap::disconnect() { bool ok = unbind(); d->handle = 0; return ok; } QLdapEntry::QLdapEntry() { } QLdapEntry::~QLdapEntry() { } QString QLdapEntry::dn() const { return mDn; } void QLdapEntry::setDn( const QString &dn ) { mDn = dn; } QStringList QLdapEntry::attributeNames() const { return mValues.keys(); } QString QLdapEntry::value( const QString &attributeName ) const { if ( !mValues.contains( attributeName ) ) return QString(); else return mValues[ attributeName ].first(); } QStringList QLdapEntry::values( const QString &attributeName ) const { if ( !mValues.contains( attributeName ) ) return QStringList(); else return mValues[ attributeName ]; } void QLdapEntry::setValue( const QString &attributeName, const QString &value ) { if ( value.isEmpty() ) return; if ( !mValues.contains( attributeName ) ) mValues.insert( attributeName, QStringList() ); mValues[ attributeName ] = QStringList( value ); } void QLdapEntry::addValue( const QString &attributeName, const QString &value ) { if ( value.isEmpty() ) return; if ( !mValues.contains( attributeName ) ) mValues.insert( attributeName, QStringList() ); mValues[ attributeName ].append( value ); } void QLdapEntry::clearValue( const QString &attributeName ) { mValues.remove( attributeName ); } void QLdapEntry::dump() const { qDebug( "dn: %s", qPrintable( mDn ) ); QMap::ConstIterator it; for ( it = mValues.begin(); it != mValues.end(); ++it ) { for ( int i = 0; i < it.value().count(); ++i ) { qDebug( "%s: %s", qPrintable( it.key() ), qPrintable( it.value()[ i ] ) ); } } qDebug( " " ); } QLdapResponse::QLdapResponse() : mValid( false ) { } QLdapResponse::~QLdapResponse() { } bool QLdapResponse::isValid() const { return mValid; } QLdapEntry::List QLdapResponse::entries() const { return mEntries; } void QLdapResponse::setEntries( const QLdapEntry::List &entries ) { mEntries = entries; mValid = true; } void QLdapResponse::dump() const { QLdapEntry::List::ConstIterator it; for ( it = mEntries.begin(); it != mEntries.end(); ++it ) (*it).dump(); } kolabadmin/entry.cpp0000644000175000017500000000502610757564566014400 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "entry.h" using namespace Form; Entry::Entry() { } Entry::~Entry() { } void Entry::setId( const QString &id ) { mId = id; } QString Entry::id() const { return mId; } QStringList Entry::keys() const { return mValues.keys(); } QString Entry::value( const QString &key ) const { if ( !mValues.contains( key ) ) return QString(); else if ( mValues[ key ].isEmpty() ) return QString(); else return mValues[ key ].first(); } QStringList Entry::values( const QString &key ) const { if ( !mValues.contains( key ) ) return QStringList(); else return mValues[ key ]; } void Entry::setValue( const QString &key, const QString &value ) { if ( !mValues.contains( key ) ) mValues.insert( key, QStringList() ); mValues[ key ] = QStringList( value ); } void Entry::addValue( const QString &key, const QString &value ) { if ( !mValues.contains( key ) ) mValues.insert( key, QStringList() ); mValues[ key ].append( value ); } void Entry::clearValue( const QString &key ) { mValues.remove( key ); } void Entry::dump() const { QMap::ConstIterator it; for ( it = mValues.begin(); it != mValues.end(); ++it ) { for ( int i = 0; i < it.value().count(); ++i ) { qDebug( "%s: %s", qPrintable( it.key() ), qPrintable( it.value()[ i ] ) ); } } qDebug( " " ); } Entry Entry::fromLdapEntry( const QLdapEntry &ldapEntry ) { Entry entry; entry.setId( ldapEntry.dn() ); QStringList names = ldapEntry.attributeNames(); for ( int i = 0; i < names.count(); ++i ) { QStringList values = ldapEntry.values( names[ i ] ); for ( int j = 0; j < values.count(); ++j ) { entry.addValue( names[ i ], values[ j ] ); } } return entry; } kolabadmin/maintainer_listingmodel.cpp0000644000175000017500000001006610757564566020140 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "maintainer_filtermodel.h" #include "maintainer_listingmodel.h" void MaintainerListingModel::doQuery( const QString &userFilter ) { QString memberBase( "cn=maintainer,cn=internal," + Connection::self()->baseDn() ); QString memberFilter( "(objectClass=kolabGroupOfNames)" ); QLdapResponse memberResponse = Connection::self()->search( memberBase, QLdap::Sub, memberFilter ); if ( !memberResponse.entries().isEmpty() ) { // get list of admin group members QStringList members = memberResponse.entries().first().values( "member" ); QLdapEntry::List adminEntries; QString blacklist; blacklist.append( "manager" ); // query all user QString filter = QString( "(&(cn=*)%1(objectClass=inetOrgPerson)(uid=*)(sn=*))" ).arg( userFilter ); QLdapResponse response = Connection::self()->search( "", QLdap::Sub, filter, QStringList(), QLatin1String( "cn" ) ); QLdapEntry::List entries = response.entries(); for ( int i = 0; i < entries.count(); ++i ) { if ( members.contains( entries[ i ].dn() ) && // is valid maintainer !blacklist.contains( entries[ i ].value( "cn" ) ) ) { // don't show blacklisted maintainers here adminEntries.append( entries[ i ] ); } } mData.setEntries( adminEntries ); } emit layoutChanged(); } int MaintainerListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 2; } int MaintainerListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant MaintainerListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return QString( "%1" ).arg( entry.value( "cn" ) ); break; case 1: return entry.value( "uid" ); break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return true; else return false; } else if ( role == ModifyActionLabelRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return tr( "Modify" ); else return tr( "Maintainer deleted, awaiting cleanup..." ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return mData.entries()[ index.row() ].dn(); else return QString(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant MaintainerListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Name" ); break; case 1: return tr( "UID" ); break; default: return QVariant(); } } FilterModel* MaintainerListingModel::filterModel() { return new MaintainerFilterModel( this ); } kolabadmin/aliasfield.h0000644000175000017500000000254110757564566015000 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ALIASFIELD_H #define FORM_ALIASFIELD_H #include "field.h" class ItemView; class AliasModel; namespace Form { class AliasField : public Field { public: AliasField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView* mView; AliasModel* mModel; QString mDn; }; } #endif kolabadmin/administrator_filtermodel.cpp0000644000175000017500000000331210757564566020501 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "administrator_filtermodel.h" AdministratorFilterModel::AdministratorFilterModel( QObject *parent ) : FilterModel( parent ) { } AdministratorFilterModel::~AdministratorFilterModel() { } int AdministratorFilterModel::rowCount( const QModelIndex& ) const { return 2; } QVariant AdministratorFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "UID" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "uid" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/auth.h0000644000175000017500000000237110757564566013645 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef AUTH_H #define AUTH_H #include class Auth { public: enum Group { Users, Maintainers, Administrators }; ~Auth(); static Auth* self(); bool authenticate( const QString &dn, QString &errorMsg ); QString dn() const; QString uid() const; Group group() const; private: Auth(); static Auth* mSelf; class Private; Private *d; }; #endif kolabadmin/service_description.h0000644000175000017500000000204710757564566016747 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SERVICE_DESCRIPTION_H #define FORM_SERVICE_DESCRIPTION_H #include "description.h" namespace Form { class ServiceDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/stringfield.cpp0000644000175000017500000000324510757564566015552 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "stringfield.h" using namespace Form; StringField::StringField( const QString &name, ValidateType type, QWidget *parent ) : Field( name, parent ), mType( type ) { mLineEdit = new QLineEdit( this ); fieldLayout()->addWidget( mLineEdit, 0, 0 ); } void StringField::loadEntry( const Entry &entry ) { mLineEdit->setText( entry.value( name() ) ); } void StringField::saveEntry( Entry &entry ) const { entry.setValue( name(), mLineEdit->text() ); } bool StringField::isValid( QString &message, PagePolicy::State ) const { if ( mType == InvalidateEmpty && mLineEdit->text().isEmpty() ) { message = QObject::tr( "You have to fill out all required fields (%1)" ).arg( name() ); return false; } else return true; } void StringField::setEditable( bool editable ) { mLineEdit->setReadOnly( !editable ); } kolabadmin/addressbook_listingmodel.cpp0000644000175000017500000000540710757564566020314 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_filtermodel.h" #include "connection.h" #include "addressbook_listingmodel.h" void AddressBookListingModel::doQuery( const QString &userFilter ) { QString filter = QString( "(&(objectClass=inetOrgPerson)%1(!(uid=*))(sn=*))" ).arg( userFilter ); mData = Connection::self()->search( "", QLdap::Sub, filter, QStringList(), QLatin1String( "givenName" ) ); emit layoutChanged(); } int AddressBookListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 1; } int AddressBookListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant AddressBookListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ); break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { return true; } else if ( role == ModifyActionLabelRole ) { return tr( "Modify" ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { return mData.entries()[ index.row() ].dn(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant AddressBookListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Name" ); break; default: return QVariant(); } } FilterModel* AddressBookListingModel::filterModel() { return new AddressBookFilterModel( this ); } kolabadmin/addressbook_policy.cpp0000644000175000017500000000242710757564566017120 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_policy.h" using namespace Form; bool AddressBookPolicy::fieldEditable( State state, const QString &fieldName ) const { if ( state == Delete ) return false; if ( state == Modify ) { if ( fieldName == "mail" ) return false; } return true; } bool AddressBookPolicy::fieldVisible( State, const QString& ) const { return true; } bool AddressBookPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/connectiondialog.cpp0000644000175000017500000002710610757564566016561 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include #include #include #include #include #include #include #include "auth.h" #include "connection.h" #include "itemview.h" #include "connectiondialog.h" ConnectionDialog::ConnectionDialog( QWidget *parent ) : QDialog( parent ) { setWindowTitle( tr( "Connection Selection" ) ); QAction* quitAction = new QAction( tr( "&Quit" ), this ); quitAction->setShortcut( Qt::CTRL + Qt::Key_Q ); connect( quitAction, SIGNAL( triggered( bool ) ), qApp, SLOT( quit() ) ); addAction( quitAction ); QGridLayout *layout = new QGridLayout( this ); QLabel *label = new QLabel( this ); QPixmap pixmap( ":kolab_logo" ); label->setPixmap( pixmap ); label->setFixedSize( pixmap.size() ); layout->addWidget( label, 0, 0, 1, 6, Qt::AlignHCenter | Qt::AlignTop ); layout->setRowMinimumHeight( 0, pixmap.size().height() + layout->spacing() * 4 ); mConnection = new QComboBox( this ); layout->addWidget( mConnection, 1, 1, 1, 4 ); label = new QLabel( tr( "&User:" ), this ); mUser = new QLineEdit( this ); label->setBuddy( mUser ); layout->addWidget( label, 2, 0 ); layout->addWidget( mUser, 2, 1, 1, 4 ); label = new QLabel( tr( "&Password:" ), this ); mPassword = new QLineEdit( this ); mPassword->setEchoMode( QLineEdit::Password ); label->setBuddy( mPassword ); layout->addWidget( label, 3, 0 ); layout->addWidget( mPassword, 3, 1, 1, 4 ); QPushButton *button = new QPushButton( tr( "&Quit" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 4, 1 ); button = new QPushButton( tr( "&Configure ..." ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( configure() ) ); layout->addWidget( button, 4, 2 ); layout->addItem( new QSpacerItem( 70, 20 ), 5, 3 ); mOkButton = new QPushButton( tr( "&Ok" ), this ); mOkButton->setDefault( true ); connect( mOkButton, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( mOkButton, 4, 4 ); mConnectionInfoManager.load(); updateButtonState(); updateConnectionBox(); } void ConnectionDialog::accept() { if ( mUser->text().isEmpty() || mPassword->text().isEmpty() ) { QMessageBox::critical( 0, QString(), tr( "You have to enter the login data!" ) ); return; } ConnectionInfo info = mConnectionInfoManager.connectionInfo( mConnection->currentText() ); if ( !info.isValid() ) { QMessageBox::critical( 0, QString(), tr( "Your selected connection is invalid!" ) ); return; } QLdap ldap( this ); ldap.setHost( info.host() ); ldap.setPort( info.port() ); ldap.setBaseDn( info.baseDn() ); ldap.setUser( info.nobodyUser() ); ldap.setPassword( info.nobodyPassword() ); const QString filter = QString( "(&(objectClass=kolabInetOrgPerson)(|(uid=%1)(mail=%2)))" ) .arg( mUser->text() ).arg( mUser->text() ); QLdapResponse response = ldap.search( info.baseDn(), QLdap::Sub, filter, QStringList( "dn" ) ); if ( !response.isValid() ) { QMessageBox::critical( this, QString(), tr( "Unable to resolve login to dn: %1" ).arg( ldap.errorString() ) ); return; } else if ( response.entries().isEmpty() ) { QMessageBox::critical( this, QString(), tr( "User '%1' is unknown to the system." ).arg( mUser->text() ) ); return; } Connection::self()->setName( info.name() ); Connection::self()->setHost( info.host() ); Connection::self()->setPort( info.port() ); Connection::self()->setBaseDn( info.baseDn() ); Connection::self()->setUser( response.entries().first().dn() ); Connection::self()->setPassword( mPassword->text() ); QString errorMsg; if ( !Auth::self()->authenticate( response.entries().first().dn(), errorMsg ) ) { QMessageBox::critical( 0, QString(), errorMsg ); return; } done( Accepted ); } void ConnectionDialog::configure() { ConfigureDialog dlg( &mConnectionInfoManager, this ); if ( dlg.exec() ) { updateButtonState(); updateConnectionBox(); mConnectionInfoManager.save(); } } void ConnectionDialog::updateButtonState() { if ( !mConnectionInfoManager.connectionInfos().isEmpty() ) { mOkButton->setEnabled( true ); mConnection->setEnabled( true ); } else { mOkButton->setEnabled( false ); mConnection->setEnabled( false ); } } void ConnectionDialog::updateConnectionBox() { const QString currentConnection = mConnection->currentText(); mConnection->clear(); const ConnectionInfo::List connections = mConnectionInfoManager.connectionInfos(); for ( int i = 0; i < connections.count(); ++i ) mConnection->addItem( connections[ i ].name() ); int index = mConnection->findText( currentConnection ); mConnection->setCurrentIndex( index == -1 ? 0 : index ); } ConnectionInfoDialog::ConnectionInfoDialog( QWidget *parent ) : QDialog( parent ) { setWindowTitle( tr( "Connection Configuration" ) ); QGridLayout *layout = new QGridLayout( this ); QLabel *label = new QLabel( tr( "Name:" ), this ); mName = new QLineEdit( this ); label->setBuddy( mName ); mName->setWhatsThis( tr( "The name of the connection that is used in the selection box of the connection dialog." ) ); layout->addWidget( label, 0, 0 ); layout->addWidget( mName, 0, 1, 1, 2 ); label = new QLabel( tr( "Host:" ), this ); mHost = new QLineEdit( this ); label->setBuddy( mHost ); mHost->setWhatsThis( tr( "The hostname or IP address of the Kolab server." ) ); layout->addWidget( label, 1, 0 ); layout->addWidget( mHost, 1, 1, 1, 2 ); label = new QLabel( tr( "Port:" ), this ); mPort = new QSpinBox( this ); mPort->setRange( 1, 65536 ); mPort->setValue( 389 ); label->setBuddy( mPort ); mPort->setWhatsThis( tr( "The port of the LDAP server." ) ); layout->addWidget( label, 2, 0 ); layout->addWidget( mPort, 2, 1, 1, 2 ); label = new QLabel( tr( "Base Dn:" ), this ); mBaseDn = new QLineEdit( this ); label->setBuddy( mBaseDn ); mBaseDn->setWhatsThis( tr( "The base dn of the Kolab server, e.g. dc=example,dc=org." ) ); layout->addWidget( label, 3, 0 ); layout->addWidget( mBaseDn, 3, 1, 1, 2 ); label = new QLabel( tr( "Nobody User:" ), this ); mUser = new QLineEdit( this ); label->setBuddy( mUser ); mUser->setWhatsThis( tr( "The dn of the nobody user, e.g. cn=nobody,cn=internal,dc=example,dc=org." ) ); layout->addWidget( label, 4, 0 ); layout->addWidget( mUser, 4, 1, 1, 2 ); label = new QLabel( tr( "Nobody Password:" ), this ); mPassword = new QLineEdit( this ); mPassword->setEchoMode( QLineEdit::Password ); label->setBuddy( mPassword ); mPassword->setWhatsThis( tr( "The password of the nobody user.\n" "You can copy & paste it (the php_pw entry) from /kolab/etc/kolab.conf" " of your Kolab installation." ) ); layout->addWidget( label, 5, 0 ); layout->addWidget( mPassword, 5, 1, 1, 2 ); QPushButton *button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 6, 1 ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 6, 2 ); } void ConnectionInfoDialog::setConnectionInfo( const ConnectionInfo &connectionInfo ) { mName->setText( connectionInfo.name() ); mHost->setText( connectionInfo.host() ); mPort->setValue( connectionInfo.port() ); mBaseDn->setText( connectionInfo.baseDn() ); mUser->setText( connectionInfo.nobodyUser() ); mPassword->setText( connectionInfo.nobodyPassword() ); } ConnectionInfo ConnectionInfoDialog::connectionInfo() const { ConnectionInfo connectionInfo( mName->text() ); connectionInfo.setHost( mHost->text() ); connectionInfo.setPort( mPort->value() ); connectionInfo.setBaseDn( mBaseDn->text() ); connectionInfo.setNobodyUser( mUser->text() ); connectionInfo.setNobodyPassword( mPassword->text() ); return connectionInfo; } void ConnectionInfoDialog::accept() { if ( mName->text().isEmpty() || mHost->text().isEmpty() || mBaseDn->text().isEmpty() || mUser->text().isEmpty() || mPassword->text().isEmpty() ) { QMessageBox::critical( this, tr( "Invalid Input" ), tr( "You have to fill out all fields." ) ); return; } QDialog::accept(); } ConfigureDialog::ConfigureDialog( ConnectionInfoManager *manager, QWidget *parent ) : QDialog( parent ), mManager( manager ) { setWindowTitle( tr( "Connection Configuration" ) ); QGridLayout *layout = new QGridLayout( this ); mWidget = new QListWidget( this ); layout->addWidget( mWidget, 0, 0, 3, 2 ); QPushButton *button = new QPushButton( tr( "&Add" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( add() ) ); layout->addWidget( button, 0, 2 ); button = new QPushButton( tr( "&Edit" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( edit() ) ); layout->addWidget( button, 1, 2 ); button = new QPushButton( tr( "&Delete" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( remove() ) ); layout->addWidget( button, 2, 2 ); button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); layout->addWidget( button, 3, 1 ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); layout->addWidget( button, 3, 2 ); const ConnectionInfo::List connections = manager->connectionInfos(); for ( int i = 0; i < connections.count(); ++i ) mWidget->addItem( connections[ i ].name() ); mWidget->setCurrentRow( 0 ); } void ConfigureDialog::add() { ConnectionInfoDialog dlg( this ); if ( !dlg.exec() ) return; const ConnectionInfo info = dlg.connectionInfo(); if ( !info.isValid() ) return; if ( mManager->contains( info.name() ) ) return; mManager->appendConnectionInfo( info ); mWidget->addItem( info.name() ); } void ConfigureDialog::edit() { QListWidgetItem *item = mWidget->currentItem(); if ( !item ) return; ConnectionInfo info = mManager->connectionInfo( item->text() ); if ( !info.isValid() ) return; ConnectionInfoDialog dlg( this ); dlg.setConnectionInfo( info ); if ( !dlg.exec() ) return; const ConnectionInfo newInfo = dlg.connectionInfo(); mManager->removeConnectionInfo( info.name() ); if ( mManager->contains( newInfo.name() ) ) mManager->appendConnectionInfo( info ); else mManager->appendConnectionInfo( newInfo ); } void ConfigureDialog::remove() { QListWidgetItem *item = mWidget->currentItem(); if ( !item ) return; mManager->removeConnectionInfo( item->text() ); delete mWidget->takeItem( mWidget->currentRow() ); } kolabadmin/user_record.h0000644000175000017500000000220510757564566015214 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_USER_RECORD_H #define FORM_USER_RECORD_H #include "record.h" namespace Form { class UserRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/tool.h0000644000175000017500000000332310757564566013657 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef TOOL_H #define TOOL_H #include #include "qldap.h" class Tool { public: static int numberOfMails( QLdap* connection, const QString &baseDn, const QString &email, const QStringList &excludedDns ); static QString dnForMailOrAlias( QLdap* connection, const QString &value ); static bool deleteObject( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow = false ); static bool deleteSharedFolder( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow = false ); static bool deleteGroupOfNames( QLdap* connection, const QString &dn, QString &errorMsg, bool deleteNow = false ); static QLdapEntry kolabSettings( QLdap* connection ); static QString randomString( int length ); static QString escape( const QString &value ); static QString escapeDn( const QString &dn ); }; #endif kolabadmin/administrator_record.h0000644000175000017500000000224010757564566017115 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADMINISTRATOR_RECORD_H #define FORM_ADMINISTRATOR_RECORD_H #include "record.h" namespace Form { class AdministratorRecord : public Record { public: virtual Entry loadEntry( const QString &id, PagePolicy::State state ); virtual bool saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ); }; } #endif kolabadmin/maintainer_page.cpp0000644000175000017500000000412410757564566016360 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "maintainer_description.h" #include "maintainer_listingmodel.h" #include "maintainer_policy.h" #include "maintainer_record.h" #include "maintainer_page.h" MaintainerPage::MaintainerPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } MaintainerPage::~MaintainerPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString MaintainerPage::name() const { return "maintainer"; } QString MaintainerPage::title() const { return QObject::tr( "Maintainers" ); } QString MaintainerPage::description() const { return QObject::tr( "Manage maintainers" ); } QString MaintainerPage::iconName() const { return "maintainer"; } ListingModel* MaintainerPage::model() { if ( !mModel ) mModel = new MaintainerListingModel; return mModel; } Form::Description* MaintainerPage::formDescription() { if ( !mDescription ) mDescription = new Form::MaintainerDescription; return mDescription; } Form::PagePolicy* MaintainerPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::MaintainerPolicy; return mPolicy; } Form::Record* MaintainerPage::formRecord() { if ( !mRecord ) mRecord = new Form::MaintainerRecord; return mRecord; } kolabadmin/booleanfield.cpp0000644000175000017500000000330110757564566015654 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "booleanfield.h" using namespace Form; BooleanField::BooleanField( const QString &name, QWidget *parent ) : Field( name, parent ) { mCheckBox = new QCheckBox( this ); fieldLayout()->addWidget( mCheckBox, 0, 0 ); } void BooleanField::loadEntry( const Entry &entry ) { if ( defaultValue() == "TRUE" ) mCheckBox->setChecked( true ); else mCheckBox->setChecked( false ); if ( entry.value( name() ) == "TRUE" ) mCheckBox->setChecked( true ); else if ( entry.value( name() ) == "FALSE" ) mCheckBox->setChecked( false ); } void BooleanField::saveEntry( Entry &entry ) const { entry.setValue( name(), ( mCheckBox->isChecked() ? "TRUE" : "FALSE" ) ); } bool BooleanField::isValid( QString&, PagePolicy::State ) const { return true; } void BooleanField::setEditable( bool editable ) { mCheckBox->setEnabled( editable ); } kolabadmin/distributionlist_description.h0000644000175000017500000000210210757564566020712 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DISTRIBUTIONLIST_DESCRIPTION_H #define FORM_DISTRIBUTIONLIST_DESCRIPTION_H #include "description.h" namespace Form { class DistributionListDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/smtphostfield.h0000644000175000017500000000253010757564566015566 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SMTPHOSTFIELD_H #define FORM_SMTPHOSTFIELD_H #include "field.h" class QLineEdit; class QSpinBox; namespace Form { class SmtpHostField : public Field { public: SmtpHostField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QLineEdit* mHost; QSpinBox* mPort; }; } #endif kolabadmin/servicesfield.h0000644000175000017500000000271710757564566015537 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SERVICESFIELD_H #define FORM_SERVICESFIELD_H #include "field.h" class QCheckBox; namespace Form { class ServicesField : public Field { public: ServicesField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QCheckBox *mPOP; QCheckBox *mPOPS; QCheckBox *mIMAP; QCheckBox *mIMAPS; QCheckBox *mSieve; QCheckBox *mFTP; QCheckBox *mHTTP; QCheckBox *mAmavis; }; } #endif kolabadmin/addressbook_page.cpp0000644000175000017500000000417010757564566016532 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "addressbook_description.h" #include "addressbook_listingmodel.h" #include "addressbook_policy.h" #include "addressbook_record.h" #include "addressbook_page.h" AddressBookPage::AddressBookPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } AddressBookPage::~AddressBookPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString AddressBookPage::name() const { return "addressbook"; } QString AddressBookPage::title() const { return QObject::tr( "Addressbook" ); } QString AddressBookPage::description() const { return QObject::tr( "Manage global LDAP address book" ); } QString AddressBookPage::iconName() const { return "addressbook"; } ListingModel* AddressBookPage::model() { if ( !mModel ) mModel = new AddressBookListingModel; return mModel; } Form::Description* AddressBookPage::formDescription() { if ( !mDescription ) mDescription = new Form::AddressBookDescription; return mDescription; } Form::PagePolicy* AddressBookPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::AddressBookPolicy; return mPolicy; } Form::Record* AddressBookPage::formRecord() { if ( !mRecord ) mRecord = new Form::AddressBookRecord; return mRecord; } kolabadmin/mailfilterfield.cpp0000644000175000017500000000522610757564566016375 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include "mailfilterfield.h" using namespace Form; MailFilterField::MailFilterField( const QString &name, QWidget *parent ) : Field( name, parent ) { mForgedHeader = new QRadioButton( this ); mNonForgedHeader = new QRadioButton( this ); QButtonGroup *group = new QButtonGroup( this ); group->addButton( mForgedHeader ); group->addButton( mNonForgedHeader ); fieldLayout()->addWidget( mForgedHeader, 0, 0 ); QLabel *label = new QLabel( tr( "Reject the message with the except if it originates from the outside but has a From header that matches the Kolab server's domain. In that case rewrite the From header so the recipient can see the potential forgery." ), this ); label->setWordWrap( true ); fieldLayout()->addWidget( label, 0, 1 ); fieldLayout()->addWidget( mNonForgedHeader, 1, 0 ); label = new QLabel( tr( "Always reject the message. Note that enabling this setting will make the server reject any mail with non-matching sender and From header if the sender is an account on this server. This is known to cause trouble for example with mailinglists." ), this ); label->setWordWrap( true ); fieldLayout()->addWidget( label, 1, 1 ); } void MailFilterField::loadEntry( const Entry &entry ) { if ( entry.value( "kolabfilter-reject-forged-from-header" ) == "TRUE" ) mForgedHeader->setChecked( true ); else mNonForgedHeader->setChecked( true ); } void MailFilterField::saveEntry( Entry &entry ) const { entry.setValue( "kolabfilter-reject-forged-from-header", mForgedHeader->isChecked() ? "TRUE" : "FALSE" ); } bool MailFilterField::isValid( QString&, PagePolicy::State ) const { return true; } void MailFilterField::setEditable( bool editable ) { mForgedHeader->setEnabled( editable ); mNonForgedHeader->setEnabled( editable ); } kolabadmin/listingmodel.h0000644000175000017500000000301710757564566015374 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef LISTINGMODEL_H #define LISTINGMODEL_H #include #include "filtermodel.h" #include "qldap.h" class ListingModel : public QAbstractTableModel { Q_OBJECT public: enum Roles { HasModifyActionRole = Qt::UserRole + 1, HasDeleteActionRole, ModifyActionLabelRole, DeleteActionLabelRole, ModifyActionIdRole, DeleteActionIdRole }; ListingModel( QObject *parent = 0 ); virtual ~ListingModel(); virtual FilterModel* filterModel() { return 0; } public Q_SLOTS: void query( const QString &filter = QString() ); protected: virtual void doQuery( const QString &filter ) = 0; QLdapResponse mData; }; #endif kolabadmin/user_policy.h0000644000175000017500000000230510757564566015236 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_USER_POLICY_H #define FORM_USER_POLICY_H #include "pagepolicy.h" namespace Form { class UserPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/service_description.cpp0000644000175000017500000001364310757564566017306 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "service_description.h" using namespace Form; Description::Entry::List ServiceDescription::entries() const { Entry::List entries; { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Administrative email addresses" ) ); entries.append( entry ); } { Entry entry; entry.setName( "distributionlists" ); entry.setType( "string" ); entry.setHeader( QObject::tr( "You have not yet set up a receiving account for the administrative email addresses hostmaster@yourdomain.tld, postmaster@yourdomain.tld, MAILER-DAEMON@yourdomain.tld, abuse@yourdomain.tld and virusalert@yourdomain.tld. Enter the email address of a kolab account below and press the button to create a distribution list for each of those addresses. Later you can add or remove people from the lists like any other distribution list" ) ); entry.setLabel( QObject::tr( "Email address:" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Enable or Disable individual Services" ) ); entries.append( entry ); } { Entry entry; entry.setName( "services" ); entry.setType( "services" ); entry.setLabel( QObject::tr( "Services" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Quota Settings" ) ); entries.append( entry ); } { Entry entry; entry.setName( "cyrus-quotawarn" ); entry.setType( "integer" ); entry.setDefaultValue( "80" ); entry.setLabel( QObject::tr( "Limit:" ) ); entry.setHeader( QObject::tr( "Warn user when quota has reached given limit" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Free/Busy Settings" ) ); entries.append( entry ); } { Entry entry; entry.setName( "apache-allow-unauthenticated-fb" ); entry.setType( "boolean" ); entry.setLabel( QObject::tr( "Allow download:" ) ); entry.setHeader( QObject::tr( "Allow unauthenticated downloading of Free/Busy information" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabFreeBusyPast" ); entry.setType( "integer" ); entry.setDefaultValue( "10" ); entry.setLabel( QObject::tr( "Days:" ) ); entry.setHeader( QObject::tr( "When creating Free/Busy lists, include data from the last given days" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Privileged Networks" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postfix-mynetworks" ); entry.setType( "networks" ); entry.setLabel( QObject::tr( "Networks:" ) ); entry.setHeader( QObject::tr( "Networks allowed to relay and send mail through unauthenticated SMTP connections to the Kolab server (networks in x.x.x.x/y format)" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "SMTP \"smarthost/relayhost\"" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postfix-relayhost" ); entry.setType( "smtphost" ); entry.setLabel( QObject::tr( "Host:" ) ); entry.setHeader( QObject::tr( "Smarthost (and optional port) to use to send outgoing mail (host.domain.tld). Leave empty for no relayhost." ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Accept Internet Mail" ) ); entries.append( entry ); } { Entry entry; entry.setName( "postfix-allow-unauthenticated" ); entry.setType( "boolean" ); entry.setLabel( QObject::tr( "Accept mails:" ) ); entry.setHeader( QObject::tr( "Accept mail from other domains over non-authenticated SMTP. This must be enabled if you want to use the Kolab server to receive mail from other internet domains." ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Mail Filter Settings" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabfilter-verify-from-header" ); entry.setType( "boolean" ); entry.setLabel( QObject::tr( "Check:" ) ); entry.setHeader( QObject::tr( "Check messages for mismatching From header and envelope from." ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabfilter-allow-sender-header" ); entry.setType( "boolean" ); entry.setLabel( QObject::tr( "Use:" ) ); entry.setHeader( QObject::tr( "Use the Sender header instead of From for the above checks if Sender is present." ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabfilter-reject-forged-from-header" ); entry.setType( "mailfilter" ); entry.setHeader( QObject::tr( "Action to take for messages that fail the check:" ) ); entries.append( entry ); } { Entry entry( Entry::GroupType ); entry.setLabel( QObject::tr( "Kolab Hosts" ) ); entries.append( entry ); } { Entry entry; entry.setName( "kolabHost" ); entry.setType( "hosts" ); entry.setLabel( "Hosts:" ); entries.append( entry ); } return entries; } kolabadmin/administrator_policy.h0000644000175000017500000000234010757564566017137 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ADMINISTRATOR_POLICY_H #define FORM_ADMINISTRATOR_POLICY_H #include "pagepolicy.h" namespace Form { class AdministratorPolicy : public PagePolicy { public: virtual bool fieldEditable( State state, const QString &name ) const; virtual bool fieldVisible( State state, const QString &name ) const; virtual bool containerEditable( State state, const QString &name ) const; }; } #endif kolabadmin/mainpolicy.cpp0000644000175000017500000000245010757564566015401 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "auth.h" #include "mainpolicy.h" bool MainPolicy::pageVisible( const QString &name ) const { if ( Auth::self()->group() == Auth::Administrators ) return true; if ( Auth::self()->group() == Auth::Maintainers ) { if ( name == "administrator" || name == "service" ) return false; else return true; } if ( Auth::self()->group() == Auth::Users ) { if ( name == "user" ) return true; else return false; } return false; } kolabadmin/hostsfield.cpp0000644000175000017500000000550610757564566015406 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "itemview.h" #include "hostsfield.h" using namespace Form; class HostModel : public QStringListModel { public: HostModel( QObject *parent = 0 ) : QStringListModel( parent ) { } virtual Qt::ItemFlags flags( const QModelIndex& ) const { return ( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } }; class HostItemView : public ItemView { public: HostItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { bool ok = true; QString host = QInputDialog::getText( this, tr( "New Kolab Host" ), tr( "Kolab Host:" ), QLineEdit::Normal, QString(), &ok ); if ( ok && !host.isEmpty() ) { QAbstractItemModel *model = mListView->model(); bool found = false; for ( int i = 0; i < model->rowCount(); ++i ) { if ( host == model->data( model->index( i, 0 ), Qt::DisplayRole ).toString() ) { found = true; break; } } if ( !found ) { int pos = model->rowCount(); model->insertRow( pos ); model->setData( model->index( pos, 0 ), host ); } } } }; HostsField::HostsField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new HostItemView( this ); mModel = new HostModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void HostsField::loadEntry( const Entry &entry ) { mModel->setStringList( entry.values( "kolabHost" ) ); } void HostsField::saveEntry( Entry &entry ) const { entry.clearValue( "kolabHost" ); const QStringList hosts = mModel->stringList(); for ( int i = 0; i < hosts.count(); ++i ) { entry.addValue( "kolabHost", hosts[ i ] ); } } bool HostsField::isValid( QString&, PagePolicy::State ) const { return true; } void HostsField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/administrator_filtermodel.h0000644000175000017500000000236610757564566020156 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADMINISTRATOR_FILTERMODEL_H #define ADMINISTRATOR_FILTERMODEL_H #include "filtermodel.h" class AdministratorFilterModel : public FilterModel { public: AdministratorFilterModel( QObject *parent = 0 ); virtual ~AdministratorFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/listingwidget.cpp0000644000175000017500000001224710757564566016117 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "listingmodel.h" #include "listingwidget.h" ListingWidget::ListingWidget( QWidget *parent ) : QTextBrowser( parent ), mModel( 0 ) { } void ListingWidget::setModel( ListingModel *model ) { if ( mModel ) disconnect( mModel, SIGNAL( changed() ), this, SLOT( update() ) ); mModel = model; connect( mModel, SIGNAL( layoutChanged() ), this, SLOT( update() ) ); } void ListingWidget::update() { clear(); if ( !mModel ) return; QString body; body += "\n"; body += "\n"; QUrl url; url.setScheme( "add" ); body += QString( "%2\n" ) .arg( url.toString() ) .arg( tr( "Create New" ) ); body += "
\n"; body += "\n"; // create table header body += "\n"; for ( int column = 0; column < mModel->columnCount(); ++column ) body += QString( "\n" ).arg( mModel->headerData( column, Qt::Horizontal ).toString() ); body += QString( "" ).arg( tr( "Actions" ) ); body += "\n"; // create table body for ( int row = 0; row < mModel->rowCount(); ++row ) { body += QString( "\n" ).arg( row % 2 == 0 ? "#C0CDE0" : "#D0DDF0" ); for ( int column = 0; column < mModel->columnCount(); ++column ) { const QModelIndex index = mModel->index( row, column ); body += QString( "\n" ).arg( mModel->data( index ).toString() ); } const QModelIndex index = mModel->index( row, 0 ); if ( mModel->data( index, ListingModel::HasModifyActionRole ).toBool() ) { QUrl url; url.setScheme( "modify" ); url.addQueryItem( "id", QString::number( row ) ); const bool hasDeleteAction = mModel->data( index, ListingModel::HasDeleteActionRole ).toBool(); const QString colspan = QString( "colspan=\"%1\"" ).arg( hasDeleteAction ? "1" : "2" ); /** * If the model returns an empty id, we don't show an active link. */ if ( mModel->data( index, ListingModel::ModifyActionIdRole ).toString().isEmpty() ) { body += QString( "\n" ) .arg( colspan ) .arg( mModel->data( index, ListingModel::ModifyActionLabelRole ).toString() ); } else { body += QString( "\n" ) .arg( colspan ) .arg( url.toString() ) .arg( mModel->data( index, ListingModel::ModifyActionLabelRole ).toString() ); } } if ( mModel->data( index, ListingModel::HasDeleteActionRole ).toBool() ) { QUrl url; url.setScheme( "delete" ); url.addQueryItem( "id", QString::number( row ) ); const bool hasModifyAction = mModel->data( index, ListingModel::HasModifyActionRole ).toBool(); const QString colspan = QString( "colspan=\"%1\"" ).arg( hasModifyAction ? "1" : "2" ); /** * If the model returns an empty id, we don't show an active link. */ if ( mModel->data( index, ListingModel::DeleteActionIdRole ).toString().isEmpty() ) { body += QString( "\n" ) .arg( colspan ) .arg( mModel->data( index, ListingModel::DeleteActionLabelRole ).toString() ); } else { body += QString( "\n" ) .arg( colspan ) .arg( url.toString() ) .arg( mModel->data( index, ListingModel::DeleteActionLabelRole ).toString() ); } } body += "\n"; } body += "
%1%1
%1%2%3%2%3
\n"; body += "
\n"; body += "\n"; body += "\n"; setHtml( body ); } void ListingWidget::setSource( const QUrl &name ) { if ( name.scheme() == "modify" || name.scheme() == "delete" ) { int id = name.queryItemValue( "id" ).toInt(); const QModelIndex index = mModel->index( id, 0 ); if ( name.scheme() == "modify" ) emit modifyEntry( mModel->data( index, ListingModel::ModifyActionIdRole ).toString() ); else emit deleteEntry( mModel->data( index, ListingModel::DeleteActionIdRole ).toString() ); } else { emit addEntry(); } } kolabadmin/invitationpolicyfield.h0000644000175000017500000000261310757564566017313 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_INVITATIONPOLICYFIELD_H #define FORM_INVITATIONPOLICYFIELD_H #include "field.h" class InvitationPolicyModel; class ItemView; namespace Form { class InvitationPolicyField : public Field { public: InvitationPolicyField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State ) const; virtual void setEditable( bool editable ); private: ItemView* mView; InvitationPolicyModel* mModel; }; } #endif kolabadmin/delegatefield.cpp0000644000175000017500000000662110757564566016017 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "connection.h" #include "itemview.h" #include "ldapsearchdialog.h" #include "delegatefield.h" using namespace Form; class DelegateModel : public QStringListModel { public: DelegateModel( QObject *parent = 0 ) : QStringListModel( parent ) { } virtual Qt::ItemFlags flags( const QModelIndex& ) const { return ( Qt::ItemIsSelectable | Qt::ItemIsEnabled ); } }; class DelegateItemView : public ItemView { public: DelegateItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { QStringList blacklist; blacklist << QString( "cn=manager,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=calendar,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=nobody,cn=internal,%1" ).arg( Connection::self()->baseDn() ); LdapSearchDialog dlg( Connection::self(), this ); dlg.setSearchFilter( "(&(objectClass=kolabInetOrgPerson)(|(mail=*%i*)))" ); dlg.setDisplayFormat( "%mail%" ); dlg.setBlackList( blacklist ); if ( dlg.exec() ) { QStringList emails = dlg.selectedValues( "mail" ); QAbstractItemModel *model = mListView->model(); for ( int i = 0; i < emails.count(); ++i ) { bool found = false; for ( int j = 0; j < model->rowCount(); ++j ) { if ( emails[ i ] == model->data( model->index( j, 0 ) ).toString() ) { found = true; break; } } if ( !found ) { int pos = model->rowCount(); model->insertRow( pos ); model->setData( model->index( pos, 0 ), emails[ i ] ); } } } } }; DelegateField::DelegateField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new DelegateItemView( this ); mModel = new DelegateModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void DelegateField::loadEntry( const Entry &entry ) { mModel->setStringList( entry.values( "kolabDelegate" ) ); } void DelegateField::saveEntry( Entry &entry ) const { entry.clearValue( "kolabDelegate" ); const QStringList delegates = mModel->stringList(); for ( int i = 0; i < delegates.count(); ++i ) { entry.addValue( "kolabDelegate", delegates[ i ] ); } } bool DelegateField::isValid( QString&, PagePolicy::State ) const { return true; } void DelegateField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/addressbook_listingmodel.h0000644000175000017500000000266410757564566017763 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ADDRESSBOOK_LISTINGMODEL_H #define ADDRESSBOOK_LISTINGMODEL_H #include "listingmodel.h" class AddressBookListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/stringfield.h0000644000175000017500000000265110757564566015217 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_STRINGFIELD_H #define FORM_STRINGFIELD_H #include "field.h" class QLineEdit; namespace Form { class StringField : public Field { public: enum ValidateType { ValidateEmpty, InvalidateEmpty }; StringField( const QString &name, ValidateType type, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: QLineEdit* mLineEdit; ValidateType mType; }; } #endif kolabadmin/sharedfolder_policy.cpp0000644000175000017500000000244610757564566017263 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sharedfolder_policy.h" using namespace Form; bool SharedFolderPolicy::fieldEditable( State state, const QString &fieldName ) const { if ( state == Delete ) return false; if ( state == Modify ) { if ( fieldName == "kolabHomeServer" ) return false; } return true; } bool SharedFolderPolicy::fieldVisible( State, const QString& ) const { return true; } bool SharedFolderPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/memberselectionfield.cpp0000644000175000017500000001350010757564566017414 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "connection.h" #include "itemview.h" #include "ldapsearchdialog.h" #include "memberselectionfield.h" using namespace Form; class MemberModel : public QAbstractListModel { public: MemberModel( QObject *parent = 0 ) : QAbstractListModel( parent ) { } virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const { return 1; } virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const { return mList.count(); } virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) return mList[ index.row() ].displayName; else if ( role == Qt::UserRole ) return mList[ index.row() ].dn; else return QVariant(); } virtual bool setData( const QModelIndex &index, const QVariant &value, int role = Qt::EditRole ) { if ( !index.isValid() ) { return false; } if ( !value.isValid() ) return false; if ( role == Qt::UserRole ) { mList[ index.row() ].dn = value.toString(); QLdapResponse response = Connection::self()->search( value.toString(), QLdap::Base, "objectClass=*" ); if ( response.isValid() && !response.entries().isEmpty() ) { QLdapEntry entry = response.entries().first(); mList[ index.row() ].displayName = QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ); } else { mList[ index.row() ].displayName = QString( "" ); } qSort( mList ); } return true; } virtual bool insertRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginInsertRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.insert( row, Entry() ); endInsertRows(); return true; } virtual bool removeRows( int row, int count, const QModelIndex &parent = QModelIndex() ) { beginRemoveRows( parent, row, row + count ); for ( int i = 0; i < count; ++i ) mList.removeAt( row ); endRemoveRows(); return true; } private: class Entry { public: QString displayName; QString dn; bool operator< ( const Entry &other ) const { return QString::localeAwareCompare( this->displayName, other.displayName ) <= 0; } }; QList mList; }; class MemberItemView : public ItemView { public: MemberItemView( QWidget *parent ) : ItemView( parent ) { } protected: virtual void doAdd() { QStringList blacklist; blacklist << QString( "cn=manager,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=calendar,cn=internal,%1" ).arg( Connection::self()->baseDn() ); blacklist << QString( "cn=nobody,cn=internal,%1" ).arg( Connection::self()->baseDn() ); LdapSearchDialog dlg( Connection::self(), this ); dlg.setSearchFilter( "(&(objectClass=kolabInetOrgPerson)(|(givenName=*%i*)(sn=*%i*)))" ); dlg.setDisplayFormat( "%sn%, %givenName% (%mail%)" ); dlg.setBlackList( blacklist ); if ( dlg.exec() ) { QStringList dns = dlg.selectedValues( "dn" ); QAbstractItemModel *model = mListView->model(); int j = model->rowCount(); for ( int i = 0; i < dns.count(); ++i ) { // check whether dn is already part of the model bool found = false; for ( int k = 0; k < model->rowCount(); ++k ) { if ( dns[ i ] == model->data( model->index( k, 0 ), Qt::UserRole ) ) found = true; } if ( !found ) { model->insertRow( j ); model->setData( model->index( j, 0 ), dns[ i ], Qt::UserRole ); ++j; } } } } }; MemberSelectionField::MemberSelectionField( const QString &name, QWidget *parent ) : Field( name, parent ) { mView = new MemberItemView( this ); mModel = new MemberModel( this ); mView->setModel( mModel ); fieldLayout()->addWidget( mView, 0, 0 ); } void MemberSelectionField::loadEntry( const Entry &entry ) { QStringList members = entry.values( "member" ); for ( int i = 0; i < members.count(); ++i ) { mModel->insertRow( i ); mModel->setData( mModel->index( i, 0 ), members[ i ], Qt::UserRole ); } } void MemberSelectionField::saveEntry( Entry &entry ) const { entry.clearValue( "member" ); for ( int i = 0; i < mModel->rowCount(); ++i ) entry.addValue( "member", mModel->data( mModel->index( i, 0 ), Qt::UserRole ).toString() ); } bool MemberSelectionField::isValid( QString &errorMsg, PagePolicy::State ) const { if ( mModel->rowCount() == 0 ) { errorMsg = QObject::tr( "You have to add at least one member!" ); return false; } else { return true; } } void MemberSelectionField::setEditable( bool editable ) { mView->setEnabled( editable ); } kolabadmin/mainwindow.h0000644000175000017500000000176010757564566015061 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINWINDOW_H #define MAINWINDOW_H #include class MainWindow : public QMainWindow { public: MainWindow( QWidget *parent = 0 ); }; #endif kolabadmin/container.cpp0000644000175000017500000001120610757564566015216 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "container.h" #include "field.h" #include "fieldfactory.h" using namespace Form; struct FieldEntry { QLabel *nameLabel; Field *field; QLabel *commentLabel; }; class Container::Private { public: QString name; QGridLayout* layout; QList fields; QWidget* baseWidget; }; Container::Container( const QString &name, QWidget *parent ) : QScrollArea( parent ), d( new Private ) { d->name = name; d->baseWidget = new QWidget; d->layout = new QGridLayout( d->baseWidget ); d->layout->setSizeConstraint( QLayout::SetFixedSize ); d->layout->setMargin( 11 ); d->layout->setSpacing( 6 ); setWidget( d->baseWidget ); setWidgetResizable( true ); // d->baseWidget->resize( d->baseWidget->sizeHint() ); } Container::~Container() { delete d; d = 0; } void Container::build( const Description *description, const PagePolicy *policy, PagePolicy::State state ) { Description::Entry::List entries = description->entries(); int rowCounter = 0; for ( int i = 0; i < entries.count(); ++i ) { if ( entries[ i ].isGroup() ) { QLabel *title = new QLabel( entries[ i ].label(), d->baseWidget ); QFont font = title->font(); font.setBold( true ); font.setPointSize( font.pointSize() + 5 ); title->setFont( font ); d->layout->addItem( new QSpacerItem( 0, 20 ), rowCounter, 0 ); rowCounter++; d->layout->addWidget( title, rowCounter, 0, 1, 3 ); rowCounter++; } else { FieldEntry entry; if ( !policy->fieldVisible( state, entries[ i ].name() ) ) continue; entry.field = FieldFactory::self()->createField( entries[ i ].type(), entries[ i ].name(), d->baseWidget ); if ( !entry.field ) continue; entry.field->setDefaultValue( entries[ i ].defaultValue() ); entry.nameLabel = new QLabel( entries[ i ].label(), d->baseWidget ); entry.commentLabel = new QLabel( entries[ i ].comment(), d->baseWidget ); entry.commentLabel->setWordWrap( true ); if ( !entries[ i ].header().isEmpty() ) { QLabel *headerLabel = new QLabel( entries[ i ].header(), d->baseWidget ); //headerLabel->setMargin( 10 ); headerLabel->setWordWrap( true ); d->layout->addWidget( headerLabel, rowCounter, 0, 1, 3 ); rowCounter++; } d->layout->addWidget( entry.nameLabel, rowCounter, 0, 1, 1, Qt::AlignTop | Qt::AlignLeft ); d->layout->addWidget( entry.field, rowCounter, 1, 1, 1, Qt::AlignTop | Qt::AlignLeft ); d->layout->addWidget( entry.commentLabel, rowCounter, 2, 1, 1, Qt::AlignTop | Qt::AlignLeft ); rowCounter++; if ( !policy->fieldEditable( state, entries[ i ].name() ) ) entry.field->setEditable( false ); d->fields.append( entry ); } } d->layout->setRowStretch( rowCounter, 1 ); } QString Container::name() const { return d->name; } QGridLayout* Container::containerLayout() const { return d->layout; } void Container::loadEntry( const Entry &entry ) { for ( int i = 0; i < d->fields.count(); ++i ) d->fields[ i ].field->loadEntry( entry ); } void Container::saveEntry( Entry &entry ) const { for ( int i = 0; i < d->fields.count(); ++i ) d->fields[ i ].field->saveEntry( entry ); } bool Container::isValid( QString &message, PagePolicy::State state ) const { bool valid = true; QString fieldMessage; for ( int i = 0; i < d->fields.count(); ++i ) { QString msg; if ( !d->fields[ i ].field->isValid( msg, state ) ) { fieldMessage.append( QString( "\n%1" ).arg( msg ) ); valid = false; } } if ( !valid ) message = fieldMessage; return valid; } void Container::setEditable( bool editable ) { for ( int i = 0; i < d->fields.count(); ++i ) { d->fields[ i ].field->setEditable( editable ); d->fields[ i ].commentLabel->setVisible( editable ); } } kolabadmin/main.cpp0000644000175000017500000000212610757564566014161 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include "connectiondialog.h" #include "mainwindow.h" int main( int argc, char **argv ) { QApplication app( argc, argv ); ConnectionDialog dlg; if ( !dlg.exec() ) return 1; MainWindow main; main.show(); return app.exec(); } kolabadmin/networksfield.h0000644000175000017500000000253710757564566015570 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_NETWORKSFIELD_H #define FORM_NETWORKSFIELD_H #include "field.h" class ItemView; class NetworkModel; namespace Form { class NetworksField : public Field { public: NetworksField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView* mView; NetworkModel* mModel; }; } #endif kolabadmin/servicesfield.cpp0000644000175000017500000001035310757564566016065 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include "servicesfield.h" using namespace Form; ServicesField::ServicesField( const QString &name, QWidget *parent ) : Field( name, parent ) { QWidget *widget = new QWidget( this ); QGridLayout *layout = new QGridLayout( widget ); layout->setMargin( 0 ); mPOP = new QCheckBox( widget ); mPOPS = new QCheckBox( widget ); mIMAP = new QCheckBox( widget ); mIMAPS = new QCheckBox( widget ); mSieve = new QCheckBox( widget ); mFTP = new QCheckBox( widget ); mHTTP = new QCheckBox( widget ); mAmavis = new QCheckBox( widget ); layout->addWidget( new QLabel( tr( "POP3 Service" ), widget ), 0, 0 ); layout->addWidget( mPOP, 0, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "POP3/SSL Service (TCP port 995)" ), widget ), 1, 0 ); layout->addWidget( mPOPS, 1, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "IMAP Service" ), widget ), 2, 0 ); layout->addWidget( mIMAP, 2, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "IMAP/SSL Service (TCP port 993)" ), widget ), 3, 0 ); layout->addWidget( mIMAPS, 3, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "Sieve Service (TCP port 2000)" ), widget ), 4, 0 ); layout->addWidget( mSieve, 4, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "FTP FreeBusy Service (Legacy, not interoperable with Kolab2 FreeBusy)" ), widget ), 5, 0 ); layout->addWidget( mFTP, 5, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "HTTP FreeBusy Service (Legacy)" ), widget ), 6, 0 ); layout->addWidget( mHTTP, 6, 1, 1, 2, Qt::AlignRight ); layout->addWidget( new QLabel( tr( "Amavis Email Scanning (Virus/Spam)" ), widget ), 7, 0 ); layout->addWidget( mAmavis, 7, 1, 1, 2, Qt::AlignRight ); fieldLayout()->addWidget( widget, 0, 0 ); } void ServicesField::loadEntry( const Entry &entry ) { mPOP->setChecked( entry.value( "cyrus-pop3" ) == "TRUE" ); mPOPS->setChecked( entry.value( "cyrus-pop3s" ) == "TRUE" ); mIMAP->setChecked( entry.value( "cyrus-imap" ) == "TRUE" ); mIMAPS->setChecked( entry.value( "cyrus-imaps" ) == "TRUE" ); mSieve->setChecked( entry.value( "cyrus-sieve" ) == "TRUE" ); mFTP->setChecked( entry.value( "proftpd-ftp" ) == "TRUE" ); mHTTP->setChecked( entry.value( "apache-http" ) == "TRUE" ); mAmavis->setChecked( entry.value( "postfix-enable-virus-scan" ) == "TRUE" ); } void ServicesField::saveEntry( Entry &entry ) const { entry.setValue( "cyrus-pop3", mPOP->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "cyrus-pop3s", mPOPS->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "cyrus-imap", mIMAP->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "cyrus-imaps", mIMAPS->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "cyrus-sieve", mSieve->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "proftpd-ftp", mFTP->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "apache-http", mHTTP->isChecked() ? "TRUE" : "FALSE" ); entry.setValue( "postfix-enable-virus-scan", mAmavis->isChecked() ? "TRUE" : "FALSE" ); } bool ServicesField::isValid( QString&, PagePolicy::State ) const { return true; } void ServicesField::setEditable( bool editable ) { mPOP->setEnabled( editable ); mPOPS->setEnabled( editable ); mIMAP->setEnabled( editable ); mIMAPS->setEnabled( editable ); mSieve->setEnabled( editable ); mFTP->setEnabled( editable ); mHTTP->setEnabled( editable ); mAmavis->setEnabled( editable ); } kolabadmin/user_listingmodel.cpp0000644000175000017500000000745010757564566016772 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "user_filtermodel.h" #include "user_listingmodel.h" void UserListingModel::doQuery( const QString &userFilter ) { QString filter = QString( "(&(objectClass=kolabInetOrgPerson)%1(uid=*)(mail=*)(sn=*))" ).arg( userFilter ); QStringList attributes; attributes << "givenName" << "sn" << "uid" << "mail" << "kolabDeleteflag"; mData = Connection::self()->search( QString(), QLdap::Sub, filter, attributes, QLatin1String( "givenName" ) ); emit layoutChanged(); } int UserListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 4; } int UserListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant UserListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: { QStringList parts = entry.dn().split( "," ); if ( parts.contains( "cn=groups" ) ) return QString( "G" ); else if ( parts.contains( "cn=resources" ) ) return QString( "R" ); else if ( parts.contains( "cn=internal" ) ) return QString( "I" ); else return QString( "U" ); } break; case 1: return QString( "%1 %2" ).arg( entry.value( "givenName" ), entry.value( "sn" ) ); break; case 2: return entry.value( "mail" ); break; case 3: return entry.value( "uid" ); break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return true; else return false; } else if ( role == ModifyActionLabelRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return tr( "Modify" ); else return tr( "User deleted, awaiting cleanup..." ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return mData.entries()[ index.row() ].dn(); else return QString(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant UserListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Type" ); break; case 1: return tr( "Name" ); break; case 2: return tr( "Email" ); break; case 3: return tr( "UID" ); break; default: return QVariant(); } } FilterModel* UserListingModel::filterModel() { return new UserFilterModel( this ); } kolabadmin/mainwidget.cpp0000644000175000017500000000507410757564566015372 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "auth.h" #include "dialog.h" #include "listingdialog.h" #include "mainpolicy.h" #include "pagemanager.h" #include "mainwidget.h" MainWidget::MainWidget( QWidget *parent ) : QTextBrowser( parent ) { mPolicy = new MainPolicy; loadPages(); } MainWidget::~MainWidget() { delete mPolicy; mPolicy = 0; } void MainWidget::loadPages() { clear(); QStringList pageNames = PageManager::self()->pageNames(); QString body; body += "\n"; body += "\n"; body += "\n"; body += QString( "" ).arg( tr( "Welcome to KolabAdmin" ) ); for ( int i = 0; i < pageNames.count(); ++i ) { // filter hidden pages if ( !mPolicy->pageVisible( pageNames[ i ] ) ) continue; Page *page = PageManager::self()->page( pageNames[ i ] ); QUrl url; url.setScheme( "open" ); url.addQueryItem( "id", page->name() ); body += "\n"; body += QString( "\n" ) .arg( page->iconName(), url.toString(), page->title(), page->description() ).arg( url.toString() ); body += "\n"; } body += "
%1
%3
%4
\n"; body += "\n"; body += "\n"; setHtml( body ); } void MainWidget::setSource( const QUrl &url ) { QString name = url.queryItemValue( "id" ); Page *page = PageManager::self()->page( name ); if ( !page ) return; if ( page->hasListingMode() ) { ListingDialog dlg( page, this ); dlg.exec(); } else { Form::Dialog dlg( page, Auth::self()->dn(), Form::PagePolicy::Modify, this ); dlg.exec(); } } kolabadmin/itemview.h0000644000175000017500000000246510757564566014541 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef ITEMVIEW_H #define ITEMVIEW_H #include #include class QAbstractButton; class ItemView : public QWidget { Q_OBJECT public: ItemView( QWidget *parent ); void setModel( QAbstractItemModel *model ); QAbstractItemModel *model() const; private Q_SLOTS: void add(); void remove(); void viewUpdated(); protected: virtual void doAdd(); QListView *mListView; private: QAbstractButton *mRemoveButton; }; #endif kolabadmin/sharedfolder_filtermodel.cpp0000644000175000017500000000332210757564566020264 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "sharedfolder_filtermodel.h" SharedFolderFilterModel::SharedFolderFilterModel( QObject *parent ) : FilterModel( parent ) { } SharedFolderFilterModel::~SharedFolderFilterModel() { } int SharedFolderFilterModel::rowCount( const QModelIndex& ) const { return 2; } QVariant SharedFolderFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "Server" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "kolabHomeServer" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/distributionlist_listingmodel.h0000644000175000017500000000270310757564566021070 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef DISTRIBUTIONLIST_LISTINGMODEL_H #define DISTRIBUTIONLIST_LISTINGMODEL_H #include "listingmodel.h" class DistributionListListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/administrator_listingmodel.cpp0000644000175000017500000001007410757564566020670 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "administrator_filtermodel.h" #include "connection.h" #include "administrator_listingmodel.h" void AdministratorListingModel::doQuery( const QString &userFilter ) { QString memberBase( "cn=admin,cn=internal," + Connection::self()->baseDn() ); QString memberFilter( "(objectClass=kolabGroupOfNames)" ); QLdapResponse memberResponse = Connection::self()->search( memberBase, QLdap::Sub, memberFilter ); if ( !memberResponse.entries().isEmpty() ) { // get list of admin group members QStringList members = memberResponse.entries().first().values( "member" ); QLdapEntry::List adminEntries; QStringList blacklist; blacklist.append( "manager" ); // query all user QString filter = QString( "(&(cn=*)(objectClass=inetOrgPerson)%1(uid=*)(sn=*))" ).arg( userFilter ); QLdapResponse response = Connection::self()->search( "", QLdap::Sub, filter, QStringList(), QLatin1String( "cn" ) ); QLdapEntry::List entries = response.entries(); for ( int i = 0; i < entries.count(); ++i ) { if ( members.contains( entries[ i ].dn() ) && // is administrator !blacklist.contains( entries[ i ].value( "cn" ) ) ) { // is not blacklisted adminEntries.append( entries[ i ] ); } } mData.setEntries( adminEntries ); } emit layoutChanged(); } int AdministratorListingModel::columnCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return 2; } int AdministratorListingModel::rowCount( const QModelIndex &parent ) const { if ( parent.isValid() ) return 0; return mData.entries().count(); } QVariant AdministratorListingModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); const QLdapEntry entry = mData.entries()[ index.row() ]; if ( role == Qt::DisplayRole ) { switch ( index.column() ) { case 0: return QString( "%1" ).arg( entry.value( "cn" ) ); break; case 1: return entry.value( "uid" ); break; default: return QVariant(); } } else if ( role == HasModifyActionRole ) { return true; } else if ( role == HasDeleteActionRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return true; else return false; } else if ( role == ModifyActionLabelRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return tr( "Modify" ); else return tr( "Administrator deleted, awaiting cleanup..." ); } else if ( role == DeleteActionLabelRole ) { return tr( "Delete" ); } else if ( role == ModifyActionIdRole ) { if ( entry.values( "kolabDeleteflag" ).isEmpty() ) return mData.entries()[ index.row() ].dn(); else return QString(); } else if ( role == DeleteActionIdRole ) { return mData.entries()[ index.row() ].dn(); } return QVariant(); } QVariant AdministratorListingModel::headerData( int section, Qt::Orientation, int role ) const { if ( role != Qt::DisplayRole ) return QVariant(); switch ( section ) { case 0: return tr( "Name" ); break; case 1: return tr( "UID" ); break; default: return QVariant(); } } FilterModel* AdministratorListingModel::filterModel() { return new AdministratorFilterModel( this ); } kolabadmin/administrator_policy.cpp0000644000175000017500000000243610757564566017500 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "administrator_policy.h" using namespace Form; bool AdministratorPolicy::fieldEditable( State state, const QString &fieldName ) const { if ( state == Delete ) return false; if ( state == Modify ) { if ( fieldName == "uid" ) return false; } return true; } bool AdministratorPolicy::fieldVisible( State, const QString& ) const { return true; } bool AdministratorPolicy::containerEditable( State, const QString& ) const { return true; } kolabadmin/distributionlist_filtermodel.cpp0000644000175000017500000000334510757564566021242 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "distributionlist_filtermodel.h" DistributionListFilterModel::DistributionListFilterModel( QObject *parent ) : FilterModel( parent ) { } DistributionListFilterModel::~DistributionListFilterModel() { } int DistributionListFilterModel::rowCount( const QModelIndex& ) const { return 2; } QVariant DistributionListFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "Member" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "member" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/connection.h0000644000175000017500000000220110757564566015033 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CONNECTION_H #define CONNECTION_H #include "qldap.h" class Connection : public QLdap { public: ~Connection(); static Connection* self(); void setName( const QString &name ); QString name() const; private: Connection(); QString mName; static Connection* mSelf; }; #endif kolabadmin/user_filtermodel.cpp0000644000175000017500000000340510757564566016602 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "user_filtermodel.h" UserFilterModel::UserFilterModel( QObject *parent ) : FilterModel( parent ) { } UserFilterModel::~UserFilterModel() { } int UserFilterModel::rowCount( const QModelIndex& ) const { return 3; } QVariant UserFilterModel::data( const QModelIndex &index, int role ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { switch ( index.row() ) { case 0: return tr( "Name" ); break; case 1: return tr( "Email" ); break; case 2: return tr( "UID" ); break; } } else if ( role == AttributeRole ) { switch ( index.row() ) { case 0: return QString( "cn" ); break; case 1: return QString( "mail" ); break; case 2: return QString( "uid" ); break; } } else if ( role == MainAttributeRole ) { return QString( "cn" ); } return QVariant(); } kolabadmin/distributionlist_record.cpp0000644000175000017500000001014710757564566020210 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "connection.h" #include "tool.h" #include "distributionlist_record.h" using namespace Form; Entry DistributionListRecord::loadEntry( const QString &id, PagePolicy::State ) { QString filter( "objectClass=*" ); QLdapResponse response = Connection::self()->search( id, QLdap::Base, filter ); if ( !response.isValid() || response.entries().isEmpty() ) return Entry(); Entry entry = Entry::fromLdapEntry( response.entries().first() ); QStringList dnParts = entry.id().split( "," ); if ( dnParts.contains( "cn=internal" ) ) entry.setValue( "hidden", "TRUE" ); else entry.setValue( "hidden", "FALSE" ); return entry; } bool DistributionListRecord::saveEntry( const Entry &entry, PagePolicy::State state, QString &errorMsg ) { if ( state == PagePolicy::Add || state == PagePolicy::Modify ) { QLdapEntry ldapEntry; QString dnRoot = Connection::self()->baseDn(); if ( entry.value( "hidden" ) == "TRUE" ) dnRoot = QString( "cn=internal,%1" ).arg( dnRoot ); ldapEntry.setValue( "objectClass", "kolabGroupOfNames" ); ldapEntry.setValue( "cn", entry.value( "cn" ) ); const QLdapEntry kolabEntry = Tool::kolabSettings( Connection::self() ); ldapEntry.setValue( "mail", entry.value( "cn" ) + "@" + kolabEntry.value( "postfix-mydomain" ) ); QStringList members = entry.values( "member" ); for ( int i = 0; i < members.count(); ++i ) ldapEntry.addValue( "member", members[ i ] ); if ( state == PagePolicy::Modify ) { QString newDn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); /** * The 'cn' of the distribution list has changed, so we have to perform some * extra checks. */ if ( entry.id() != newDn ) { if ( !Connection::self()->add( newDn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify distribution list '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } if ( !Connection::self()->remove( entry.id() ) ) { errorMsg = QObject::tr( "Could not modify distribution list '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } else { if ( !Connection::self()->modifyAttributes( entry.id(), ldapEntry ) ) { errorMsg = QObject::tr( "Could not modify distribution list '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Add ) { QString dn = QString( "cn=%1,%2" ).arg( ldapEntry.value( "cn" ), dnRoot ); if ( !Connection::self()->add( dn, ldapEntry ) ) { errorMsg = QObject::tr( "Could not add distribution list '%1': %2" ) .arg( ldapEntry.value( "cn" ), Connection::self()->errorString() ); return false; } } } else if ( state == PagePolicy::Delete ) { QString ldapError; if ( !Tool::deleteGroupOfNames( Connection::self(), entry.id(), ldapError ) ) { errorMsg = QObject::tr( "Could not delete distribution list '%1': %2" ) .arg( entry.value( "cn" ), ldapError ); return false; } } return true; } kolabadmin/sharedfolder_description.h0000644000175000017500000000206610757564566017752 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_SHAREDFOLDER_DESCRIPTION_H #define FORM_SHAREDFOLDER_DESCRIPTION_H #include "description.h" namespace Form { class SharedFolderDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/user_page.cpp0000644000175000017500000000413210757564566015206 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "auth.h" #include "user_description.h" #include "user_listingmodel.h" #include "user_policy.h" #include "user_record.h" #include "user_page.h" UserPage::UserPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } UserPage::~UserPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString UserPage::name() const { return "user"; } QString UserPage::title() const { return QObject::tr( "Users" ); } QString UserPage::description() const { return QObject::tr( "Manage email users" ); } QString UserPage::iconName() const { return "user"; } bool UserPage::hasListingMode() const { if ( Auth::self()->group() == Auth::Users ) return false; else return true; } ListingModel* UserPage::model() { if ( !mModel ) mModel = new UserListingModel; return mModel; } Form::Description* UserPage::formDescription() { if ( !mDescription ) mDescription = new Form::UserDescription; return mDescription; } Form::PagePolicy* UserPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::UserPolicy; return mPolicy; } Form::Record* UserPage::formRecord() { if ( !mRecord ) mRecord = new Form::UserRecord; return mRecord; } kolabadmin/administrator_page.cpp0000644000175000017500000000423710757564566017116 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "administrator_description.h" #include "administrator_listingmodel.h" #include "administrator_policy.h" #include "administrator_record.h" #include "administrator_page.h" AdministratorPage::AdministratorPage() : mModel( 0 ), mDescription( 0 ), mPolicy( 0 ), mRecord( 0 ) { } AdministratorPage::~AdministratorPage() { delete mModel; mModel = 0; delete mDescription; mDescription = 0; delete mPolicy; mPolicy = 0; delete mRecord; mRecord = 0; } QString AdministratorPage::name() const { return "administrator"; } QString AdministratorPage::title() const { return QObject::tr( "Administrators" ); } QString AdministratorPage::description() const { return QObject::tr( "Manage Administrators" ); } QString AdministratorPage::iconName() const { return "administrator"; } ListingModel* AdministratorPage::model() { if ( !mModel ) mModel = new AdministratorListingModel; return mModel; } Form::Description* AdministratorPage::formDescription() { if ( !mDescription ) mDescription = new Form::AdministratorDescription; return mDescription; } Form::PagePolicy* AdministratorPage::formPolicy() { if ( !mPolicy ) mPolicy = new Form::AdministratorPolicy; return mPolicy; } Form::Record* AdministratorPage::formRecord() { if ( !mRecord ) mRecord = new Form::AdministratorRecord; return mRecord; } kolabadmin/aclselectionfield.h0000644000175000017500000000331010757564566016347 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_ACLSELECTIONFIELD_H #define FORM_ACLSELECTIONFIELD_H #include #include "field.h" class QComboBox; class QLineEdit; class ItemView; class AclModel; namespace Form { class AclSelectionField : public Field { public: AclSelectionField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView *mView; AclModel *mModel; }; class AclDialog : public QDialog { Q_OBJECT public: AclDialog( QWidget *parent = 0 ); QStringList acl() const; private Q_SLOTS: void selectUid(); protected: virtual void accept(); private: QLineEdit *mUidLabel; QComboBox *mRights; QString mUid; }; } #endif kolabadmin/sharedfolder_listingmodel.h0000644000175000017500000000266710757564566020130 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef SHAREDFOLDER_LISTINGMODEL_H #define SHAREDFOLDER_LISTINGMODEL_H #include "listingmodel.h" class SharedFolderListingModel : public ListingModel { public: virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const; virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; virtual QVariant headerData( int section, Qt::Orientation, int role = Qt::DisplayRole ) const; virtual FilterModel* filterModel(); protected: virtual void doQuery( const QString &filter ); }; #endif kolabadmin/maintainer_filtermodel.h0000644000175000017500000000234710757564566017424 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef MAINTAINER_FILTERMODEL_H #define MAINTAINER_FILTERMODEL_H #include "filtermodel.h" class MaintainerFilterModel : public FilterModel { public: MaintainerFilterModel( QObject *parent = 0 ); virtual ~MaintainerFilterModel(); virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const; virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const; }; #endif kolabadmin/delegatefield.h0000644000175000017500000000254110757564566015461 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DELEGATEFIELD_H #define FORM_DELEGATEFIELD_H #include "field.h" class ItemView; class DelegateModel; namespace Form { class DelegateField : public Field { public: DelegateField( const QString &name, QWidget *parent ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: ItemView* mView; DelegateModel* mModel; }; } #endif kolabadmin/crypto.h0000644000175000017500000000202310757564566014216 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef CRYPTO_H #define CRYPTO_H #include class Crypto { public: /** * Returns a SHA1 hash for data. */ static QByteArray sha1( const QByteArray &data ); }; #endif kolabadmin/ldapsearchdialog.cpp0000644000175000017500000001465210757564566016532 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include #include #include #include #include #include "ldapsearchdialog.h" class LdapModel : public QAbstractListModel { public: LdapModel( QLdap *connection, QObject *parent = 0 ) : QAbstractListModel( parent ), mConnection( connection ) { } virtual int columnCount( const QModelIndex &parent = QModelIndex() ) const { return 1; } virtual int rowCount( const QModelIndex &parent = QModelIndex() ) const { return mList.count(); } virtual QVariant data( const QModelIndex &index, int role = Qt::DisplayRole ) const { if ( !index.isValid() ) return QVariant(); if ( role == Qt::DisplayRole ) { if ( mDisplayFormat.isEmpty() ) return mList[ index.row() ].dn(); QLdapEntry entry = mList[ index.row() ]; QString data = mDisplayFormat; const QStringList attributeNames = entry.attributeNames(); for ( int i = 0; i < attributeNames.count(); ++i ) { data.replace( QString( "%" ) + attributeNames[ i ] + QString( "%" ), entry.value( attributeNames[ i ] ) ); } return data; } else if ( role == Qt::UserRole ) { if ( mResultKey.isEmpty() || mResultKey.toLower() == "dn" ) return mList[ index.row() ].dn(); else return mList[ index.row() ].value( mResultKey ); } else return QVariant(); } void setSearchFilter( const QString &searchFilter ) { mSearchFilter = searchFilter; } void setDisplayFormat( const QString &displayFormat ) { mDisplayFormat = displayFormat; } void setBlackList( const QStringList &blacklist ) { mBlackList = blacklist; } void setResultKey( const QString &key ) { mResultKey = key; } QLdapEntry entry( const QModelIndex &index ) { return mList[ index.row() ]; } void query( const QString &input ) { QString filter = mSearchFilter; filter.replace( "%i", (input.isEmpty() ? "*" : input) ); // normalize wildcards while ( filter.contains( "**" ) ) filter.replace( "**", "*" ); QLdapResponse response = mConnection->search( mConnection->baseDn(), QLdap::Sub, filter, QStringList(), QLatin1String( "sn" ) ); if ( response.isValid() ) { mList.clear(); QLdapEntry::List entries = response.entries(); for ( int i = 0; i < entries.count(); ++i ) if ( !mBlackList.contains( entries[ i ].dn() ) ) mList.append( entries[ i ] ); } else mList.clear(); reset(); } private: QLdapEntry::List mList; QString mSearchFilter; QString mDisplayFormat; QStringList mBlackList; QString mResultKey; QLdap* mConnection; }; class LdapSearchDialog::Private { public: Private( QLdap *connection ) { model = new LdapModel( connection ); } ~Private() { delete model; model = 0; } LdapModel* model; QLineEdit* searchText; QPushButton* button; QListView* view; }; LdapSearchDialog::LdapSearchDialog( QLdap* connection, QWidget *parent ) : QDialog( parent ), d( new Private( connection ) ) { QGridLayout *layout = new QGridLayout( this ); QLabel *label = new QLabel( tr( "Filter:" ), this ); layout->addWidget( label, 0, 0 ); d->searchText = new QLineEdit( this ); label->setBuddy( d->searchText ); layout->addWidget( d->searchText, 0, 1 ); d->button = new QPushButton( tr( "Search" ), this ); layout->addWidget( d->button, 0, 2 ); connect( d->button, SIGNAL( clicked() ), this, SLOT( search() ) ); d->view = new QListView( this ); d->view->setSelectionMode( QAbstractItemView::MultiSelection ); d->view->setModel( d->model ); layout->addWidget( d->view, 1, 0, 1, 3 ); QHBoxLayout *buttonLayout = new QHBoxLayout; layout->addLayout( buttonLayout, 2, 0, 1, 3 ); QPushButton *button = new QPushButton( tr( "&Ok" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( accept() ) ); buttonLayout->addWidget( button, 0, Qt::AlignRight ); button = new QPushButton( tr( "&Cancel" ), this ); connect( button, SIGNAL( clicked() ), this, SLOT( reject() ) ); buttonLayout->addWidget( button, 0, Qt::AlignRight ); } LdapSearchDialog::~LdapSearchDialog() { delete d; d = 0; } void LdapSearchDialog::setSearchFilter( const QString &searchFilter ) { d->model->setSearchFilter( searchFilter ); } void LdapSearchDialog::setDisplayFormat( const QString &displayFormat ) { d->model->setDisplayFormat( displayFormat ); } void LdapSearchDialog::setBlackList( const QStringList &blacklist ) { d->model->setBlackList( blacklist ); } QStringList LdapSearchDialog::selectedValues( const QString& key ) const { QStringList values; QItemSelectionModel *selectionModel = d->view->selectionModel(); QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); d->model->setResultKey( key ); for ( int i = 0; i < selectedIndexes.count(); ++i ) { values.append( d->model->data( selectedIndexes[ i ], Qt::UserRole ).toString() ); } return values; } QLdapEntry::List LdapSearchDialog::selectedEntries() const { QItemSelectionModel *selectionModel = d->view->selectionModel(); QModelIndexList selectedIndexes = selectionModel->selectedIndexes(); QLdapEntry::List entries; for ( int i = 0; i < selectedIndexes.count(); ++i ) entries.append( d->model->entry( selectedIndexes[ i ] ) ); return entries; } void LdapSearchDialog::search() { d->model->query( d->searchText->text() ); } kolabadmin/user_description.h0000644000175000017500000000203610757564566016263 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_USER_DESCRIPTION_H #define FORM_USER_DESCRIPTION_H #include "description.h" namespace Form { class UserDescription : public Description { public: virtual Entry::List entries() const; }; } #endif kolabadmin/container.h0000644000175000017500000000312510757564566014664 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_CONTAINER_H #define FORM_CONTAINER_H #include #include #include "description.h" #include "entry.h" #include "pagepolicy.h" namespace Form { class Container : public QScrollArea { public: Container( const QString &name, QWidget *parent ); ~Container(); QString name() const; QGridLayout* containerLayout() const; virtual void build( const Description *description, const PagePolicy *policy, PagePolicy::State state ); virtual void loadEntry( const Entry &entry ); virtual void saveEntry( Entry &entry ) const; virtual bool isValid( QString &message, PagePolicy::State state ) const; virtual void setEditable( bool editable ); private: class Private; Private *d; }; } #endif kolabadmin/description.h0000644000175000017500000000417310757564566015231 0ustar tobiastobias/* This file is part of KolabAdmin. Copyright (C) 2006 Tobias Koenig This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #ifndef FORM_DESCRIPTION_H #define FORM_DESCRIPTION_H #include namespace Form { class Description { public: class Entry { public: typedef QList List; enum Type { EntryType, GroupType }; Entry( Type type = EntryType ); void setName( const QString &name ); QString name() const; void setType( const QString &type ); QString type() const; void setValidator( const QString &validator ); QString validator() const; void setLabel( const QString &label ); QString label() const; void setHeader( const QString &header ); QString header() const; void setComment( const QString &comment ); QString comment() const; void setDefaultValue( const QString &value ); QString defaultValue() const; bool isGroup() const; private: QString mName; QString mType; QString mValidator; QString mLabel; QString mHeader; QString mComment; QString mDefaultValue; Type mEntryType; }; Description(); virtual ~Description(); /** * Returns the list of field descriptions. */ virtual Entry::List entries() const; }; } #endif