summaryrefslogtreecommitdiffstats
path: root/src/modules/url
diff options
context:
space:
mode:
authortpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
committertpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da>2010-02-24 02:13:59 +0000
commita6d58bb6052ac8cb01805a48c4ad2f129126116f (patch)
treedd867a099fcbb263a8009a9fb22695b87855dad6 /src/modules/url
downloadkvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.tar.gz
kvirc-a6d58bb6052ac8cb01805a48c4ad2f129126116f.zip
Added KDE3 version of kvirc
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/kvirc@1095341 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'src/modules/url')
-rw-r--r--src/modules/url/Makefile.am23
-rw-r--r--src/modules/url/caps/Makefile.am9
-rw-r--r--src/modules/url/caps/url0
-rw-r--r--src/modules/url/icons.h554
-rw-r--r--src/modules/url/libkviurl.cpp910
-rw-r--r--src/modules/url/libkviurl.h144
6 files changed, 1640 insertions, 0 deletions
diff --git a/src/modules/url/Makefile.am b/src/modules/url/Makefile.am
new file mode 100644
index 00000000..c2d88957
--- /dev/null
+++ b/src/modules/url/Makefile.am
@@ -0,0 +1,23 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <[email protected]>
+###############################################################################
+
+SUBDIRS = caps
+
+AM_CPPFLAGS = -I$(SS_TOPSRCDIR)/src/kvilib/include/ -I$(SS_TOPSRCDIR)/src/kvirc/include/ \
+$(SS_INCDIRS) $(SS_CPPFLAGS) -DGLOBAL_KVIRC_DIR=\"$(globalkvircdir)\"
+
+pluglib_LTLIBRARIES = libkviurl.la
+
+libkviurl_la_LDFLAGS = -module -avoid-version $(SS_LDFLAGS) $(SS_LIBDIRS)
+
+libkviurl_la_SOURCES = libkviurl.cpp
+libkviurl_la_LIBADD = $(SS_LIBLINK) ../../kvilib/build/libkvilib.la
+
+
+noinst_HEADERS= libkviurl.h icons.h
+
+%.moc: %.h
+ $(SS_QT_MOC) $< -o $@
+
+libkviurl.cpp: libkviurl.moc
diff --git a/src/modules/url/caps/Makefile.am b/src/modules/url/caps/Makefile.am
new file mode 100644
index 00000000..231fa79c
--- /dev/null
+++ b/src/modules/url/caps/Makefile.am
@@ -0,0 +1,9 @@
+###############################################################################
+# KVirc IRC client Makefile - 10.03.2000 Szymon Stefanek <[email protected]>
+###############################################################################
+
+tmpdir = $(pluglibdir)/caps/action/
+
+tmp_DATA= url
+
+EXTRA_DIST = $(tmp_DATA)
diff --git a/src/modules/url/caps/url b/src/modules/url/caps/url
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/src/modules/url/caps/url
diff --git a/src/modules/url/icons.h b/src/modules/url/icons.h
new file mode 100644
index 00000000..20cc7823
--- /dev/null
+++ b/src/modules/url/icons.h
@@ -0,0 +1,554 @@
+const char * url_icon_xpm[] = {
+"16 16 104 2",
+" c None",
+". c #FFFFFF",
+"+ c #F7F7F7",
+"@ c #EFEFEF",
+"# c #E7E7E7",
+"$ c #DFDFDF",
+"% c #D7D7D7",
+"& c #CFCFCF",
+"* c #C7C7C7",
+"= c #BFBFBF",
+"- c #B7B7B7",
+"; c #AFAFAF",
+"> c #A7A7A7",
+", c #9F9F9F",
+"' c #979797",
+") c #8F8F8F",
+"! c #878787",
+"~ c #000000",
+"{ c #090909",
+"] c #121212",
+"^ c #1B1B1B",
+"/ c #242424",
+"( c #2D2D2D",
+"_ c #363636",
+": c #3F3F3F",
+"< c #484848",
+"[ c #515151",
+"} c #5B5B5B",
+"| c #646464",
+"1 c #6D6D6D",
+"2 c #767676",
+"3 c #7F7F7F",
+"4 c #C0C0C0",
+"5 c #AEAEAE",
+"6 c #A5A5A5",
+"7 c #9B9B9B",
+"8 c #929292",
+"9 c #898989",
+"0 c #777777",
+"a c #A7BED2",
+"b c #97C5EC",
+"c c #95C8F4",
+"d c #96BDE0",
+"e c #929DA7",
+"f c #8B96A0",
+"g c #90B7D9",
+"h c #90BDE4",
+"i c #798FA3",
+"j c #888888",
+"k c #6F6F6F",
+"l c #8AACCA",
+"m c #738493",
+"n c #5A5A5A",
+"o c #919191",
+"p c #676767",
+"q c #A3A8AD",
+"r c #94BBDE",
+"s c #8CB3D5",
+"t c #66727B",
+"u c #9A9A9A",
+"v c #5F5F5F",
+"w c #99AAB8",
+"x c #91B3D0",
+"y c #A3A3A3",
+"z c #575757",
+"A c #94B6D3",
+"B c #8697A6",
+"C c #7EA0BD",
+"D c #3E3E3E",
+"E c #ADADAD",
+"F c #4F4F4F",
+"G c #92B9DC",
+"H c #797F83",
+"I c #636363",
+"J c #748A9E",
+"K c #728EA7",
+"L c #353535",
+"M c #B6B6B6",
+"N c #474747",
+"O c #85ADCF",
+"P c #515C65",
+"Q c #2C2C2C",
+"R c #91BEE5",
+"S c #5F6B74",
+"T c #81A9CB",
+"U c #222222",
+"V c #C8C8C8",
+"W c #373737",
+"X c #7A8B9A",
+"Y c #8FBCE3",
+"Z c #87AFD1",
+"` c #3F4549",
+" . c #191919",
+".. c #D1D1D1",
+"+. c #2F2F2F",
+"@. c #101010",
+"#. c #DADADA",
+"$. c #272727",
+"%. c #060606",
+"&. c #E3E3E3",
+"*. c #1F1F1F",
+"=. c #ECECEC",
+"-. c #171717",
+";. c #0F0F0F",
+". + @ # $ % & * = - ; > , ' ) ! ",
+"+ ~ { ] ^ / ( _ : < [ } | 1 2 3 ",
+"@ { 4 4 4 - 5 6 7 8 9 3 2 1 3 0 ",
+"# ] 4 4 a b c d e f g c h i j k ",
+"$ ^ 4 - 5 c c 8 9 3 l c m n o p ",
+"% / - 5 q c r 9 3 2 s c t [ u v ",
+"& ( 5 6 w c x 3 2 1 c c [ < y z ",
+"* _ 6 7 A c B 2 1 m c C < D E F ",
+"= : 7 8 G c H 1 I J c K D L M N ",
+"- < 8 9 c c 1 I n O c P L Q = : ",
+"; [ 9 3 R c I n S c T L Q U V W ",
+"> } 3 2 X Y Z C c T ` Q U ...+.",
+", | 2 1 I n [ < D L Q U .@.#.$.",
+"' 1 1 I n [ < D L Q U .@.%.&.*.",
+") 2 3 j o u y E M = V ..#.&.=.-.",
+"! 3 0 k p v z F N : W +.$.*.-.;."};
+
+const char * url_toolbar_xpm[] = {
+"32 32 38 1",
+" c None",
+". c #000000",
+"+ c #FFFBFF",
+"@ c #B6C3FF",
+"# c #B6C3A6",
+"$ c #FFFFFF",
+"% c #836977",
+"& c #710818",
+"* c #20000E",
+"= c #710018",
+"- c #B60818",
+"; c #710000",
+"> c #A36B7E",
+", c #20050E",
+"' c #FFDFCF",
+") c #B60018",
+"! c #B60800",
+"~ c #B60000",
+"{ c #B62018",
+"] c #B64118",
+"^ c #FF2018",
+"/ c #B62000",
+"( c #B66B7E",
+"_ c #040001",
+": c #FF4118",
+"< c #B66908",
+"[ c #58321C",
+"} c #FF6918",
+"| c #B64100",
+"1 c #FFC3A6",
+"2 c #20252F",
+"3 c #FF4100",
+"4 c #EA6B7E",
+"5 c #713051",
+"6 c #A25E06",
+"7 c #B6727E",
+"8 c #B64151",
+"9 c #4A3211",
+"................+@..............",
+"................++..............",
+"................++..............",
+"................+++.............",
+"................+++.............",
+"................+++.............",
+"................#++@...#$#......",
+"................@+++..@+++@.....",
+"................#+++..+++++.....",
+"................@++++#+++++%....",
+"................#++++++++++#....",
+"......++@.......++++++++++$.....",
+".....++++@......++++++.+++......",
+".&..@++++++....+++++++..........",
+"&&&*++++++++...+++++++..........",
+"&&=++++++++++.+++++++++.........",
+"-;>++&&.#++++++++++++++.........",
+";-+>=&&&,'+++++++++++++#........",
+");-;=;&&&*#++++++$$.#+++........",
+"!-~-)-=-&&,+++++++...+++........",
+".{{!-;);-;&=#+++++@...++#.......",
+"..]^!-~-;-=&='+++++...@++.......",
+"...{{/{~);-;=;>+++++...++.......",
+".....{/^!-~-)-=#++++@...+@......",
+"......{/^!-!-;);(++++_...+......",
+"........]:/^!-~-;#+++@,..@......",
+".........<:/{!-~);(+++&*,.......",
+"..........[}|:/^!-~1+++-&&......",
+"............}|:/^!-~(++>&;&2....",
+".............[3:|:/^!4++;-=5....",
+"...............<6|:/{!7+#;-;8...",
+"................9}|}|:/1+-~-)..."};
+
+const char * urlhigh_toolbar_xpm[] = {
+"32 32 33 1",
+" c None",
+". c #000000",
+"+ c #D4FF00",
+"@ c #E1FF3A",
+"# c #710818",
+"$ c #20000E",
+"% c #710018",
+"& c #B60818",
+"* c #710000",
+"= c #20050E",
+"- c #B60018",
+"; c #B60800",
+"> c #B60000",
+", c #B62018",
+"' c #B64118",
+") c #FF2018",
+"! c #B62000",
+"~ c #A36B7E",
+"{ c #B66B7E",
+"] c #040001",
+"^ c #FF4118",
+"/ c #B66908",
+"( c #58321C",
+"_ c #FF6918",
+": c #B64100",
+"< c #20252F",
+"[ c #FF4100",
+"} c #EA6B7E",
+"| c #713051",
+"1 c #A25E06",
+"2 c #B6727E",
+"3 c #B64151",
+"4 c #4A3211",
+"................+@..............",
+"................++..............",
+"................++..............",
+"................+++.............",
+"................+++.............",
+"................+++.............",
+"................@++@...@+@......",
+"................@+++..@+++@.....",
+"................@+++..+++++.....",
+"................@++++@+++++@....",
+"................@++++++++++@....",
+"......++@.......+++++++++++.....",
+".....++++@......++++++.+++......",
+".#..@++++++....+++++++..........",
+"###$++++++++...+++++++..........",
+"##%++++++++++.+++++++++.........",
+"&*@++##.@++++++++++++++.........",
+"*&@@%###=@+++++++++++++@........",
+"-*&*%*###$@++++++++.@+++........",
+";&>&-&%&##=+++++++...+++........",
+".,,;&*-*&*#%@+++++@...++@.......",
+"..');&>&*&%#%@+++++...@++.......",
+"...,,!,>-*&*%*~+++++...++.......",
+".....,!);&>&-&%@++++@...+@......",
+"......,!);&;&*-*{++++]...@......",
+"........'^!);&>&*@@++@=..@......",
+"........./^!,;&>-*{+++#$=.......",
+"..........(_:^!);&>@+++&##......",
+"............_:^!);&>{++~#*#<....",
+".............([^:^!);}++*&%|....",
+".............../1:^!,;2+@*&*3...",
+"................4_:_:^!@@&>&-..."};
+
+const char * urlconf_toolbar_xpm[] = {
+"32 32 256 2",
+" c None",
+". c #000000",
+"+ c #FFFBFF",
+"@ c #B6C3FF",
+"# c #B6C3A6",
+"$ c #FFFFFF",
+"% c #836977",
+"& c #710818",
+"* c #F8F5F8",
+"= c #212121",
+"- c #0F0F0F",
+"; c #060606",
+"> c #20000E",
+", c #EAE7EA",
+"' c #D3D2D3",
+") c #E3E1E3",
+"! c #FCF9FC",
+"~ c #BEBCBE",
+"{ c #858585",
+"] c #545454",
+"^ c #323232",
+"/ c #010101",
+"( c #710018",
+"_ c #FEFAFE",
+": c #C3C1C3",
+"< c #9E9E9E",
+"[ c #B7B7B7",
+"} c #A5A5A5",
+"| c #C0BFC0",
+"1 c #EEECEE",
+"2 c #848384",
+"3 c #757575",
+"4 c #828282",
+"5 c #4A4A4A",
+"6 c #83C6C6",
+"7 c #B60818",
+"8 c #710000",
+"9 c #A36B7E",
+"0 c #FCF8FC",
+"a c #767576",
+"b c #272727",
+"c c #3D3D3D",
+"d c #707070",
+"e c #9B9B9B",
+"f c #ABABAB",
+"g c #9D9D9D",
+"h c #8A8A8A",
+"i c #999999",
+"j c #9E9D9E",
+"k c #CDCBCD",
+"l c #FBF7FB",
+"m c #F1EEF1",
+"n c #EEEBEE",
+"o c #A46D80",
+"p c #703441",
+"q c #242020",
+"r c #353535",
+"s c #888888",
+"t c #A3A3A3",
+"u c #949494",
+"v c #959595",
+"w c #A3A1A3",
+"x c #A09FA0",
+"y c #868586",
+"z c #FAF7FA",
+"A c #B60018",
+"B c #720303",
+"C c #B91221",
+"D c #770C0C",
+"E c #883446",
+"F c #948888",
+"G c #6A6A6A",
+"H c #6D6D6D",
+"I c #9F9F9F",
+"J c #AAAAAA",
+"K c #A1A1A1",
+"L c #A4A4A4",
+"M c #A0A0A0",
+"N c #939393",
+"O c #898989",
+"P c #6B6B6B",
+"Q c #C9C9C9",
+"R c #B60800",
+"S c #B1303C",
+"T c #8B5151",
+"U c #A06D72",
+"V c #B28D91",
+"W c #B6B3B3",
+"X c #9C9C9C",
+"Y c #B1B1B1",
+"Z c #B3B3B3",
+"` c #AFAFAF",
+" . c #A6A59E",
+".. c #B5A874",
+"+. c #B3A46A",
+"@. c #949287",
+"#. c #919191",
+"$. c #939293",
+"%. c #171717",
+"&. c #A85752",
+"*. c #686463",
+"=. c #8C8C8C",
+"-. c #BBBBBB",
+";. c #C2C2C2",
+">. c #BEBEBE",
+",. c #BDBDBD",
+"'. c #ADACAC",
+"). c #8F7E3D",
+"!. c #D1B440",
+"~. c #CDAF39",
+"{. c #BDA64A",
+"]. c #9F9E98",
+"^. c #989898",
+"/. c #7F7F7F",
+"(. c #B7C2F5",
+"_. c #414141",
+":. c #525151",
+"<. c #616161",
+"[. c #7A7A7A",
+"}. c #B6B6B6",
+"|. c #C3C3C3",
+"1. c #85847F",
+"2. c #A58F3B",
+"3. c #E5C752",
+"4. c #D7BA47",
+"5. c #CBAE3C",
+"6. c #9F9981",
+"7. c #A2A2A2",
+"8. c #7E7E7E",
+"9. c #CFCDCF",
+"0. c #0D0D0D",
+"a. c #2C2C2C",
+"b. c #141414",
+"c. c #100C0C",
+"d. c #505050",
+"e. c #C6C6C6",
+"f. c #CACACA",
+"g. c #A9A9A7",
+"h. c #5A5027",
+"i. c #D4BB58",
+"j. c #E8CB57",
+"k. c #D0B651",
+"l. c #99968B",
+"m. c #979797",
+"n. c #6F6F6F",
+"o. c #070707",
+"p. c #202020",
+"q. c #2F2F2F",
+"r. c #383838",
+"s. c #585858",
+"t. c #7C7C7C",
+"u. c #969696",
+"v. c #CECECE",
+"w. c #C3C2C2",
+"x. c #888784",
+"y. c #44433C",
+"z. c #89805E",
+"A. c #8F8D83",
+"B. c #8F8F8F",
+"C. c #3A3A3A",
+"D. c #9DA4C6",
+"E. c #343434",
+"F. c #575757",
+"G. c #909090",
+"H. c #D0D0D0",
+"I. c #D5D5D5",
+"J. c #CBCBCB",
+"K. c #BFBFBF",
+"L. c #C4C4C4",
+"M. c #AEAEAE",
+"N. c #BABABA",
+"O. c #B0B0B0",
+"P. c #666666",
+"Q. c #2D2D2D",
+"R. c #C0BEC0",
+"S. c #040001",
+"T. c #020202",
+"U. c #373737",
+"V. c #363636",
+"W. c #565656",
+"X. c #D4D4D4",
+"Y. c #C1C1C1",
+"Z. c #C7C7C7",
+"`. c #C5C5C5",
+" + c #C0C0C0",
+".+ c #B2B2B2",
+"++ c #696968",
+"@+ c #B8B6B8",
+"#+ c #F2EEF2",
+"$+ c #FDF9FD",
+"%+ c #20050E",
+"&+ c #404040",
+"*+ c #4D4D4D",
+"=+ c #646464",
+"-+ c #5F5F5F",
+";+ c #5D5D5D",
+">+ c #929292",
+",+ c #8D8A8A",
+"'+ c #AA808A",
+")+ c #080808",
+"!+ c #424242",
+"~+ c #2E2E2E",
+"{+ c #1A1A1A",
+"]+ c #313131",
+"^+ c #3C3C3C",
+"/+ c #4B4B4B",
+"(+ c #C8C8C8",
+"_+ c #A6A6A6",
+":+ c #484848",
+"<+ c #633636",
+"[+ c #FFC7AB",
+"}+ c #303030",
+"|+ c #3B3B3B",
+"1+ c #1D1D1D",
+"2+ c #282828",
+"3+ c #393939",
+"4+ c #7D7D7D",
+"5+ c #262423",
+"6+ c #1B1A19",
+"7+ c #191919",
+"8+ c #4B2B2E",
+"9+ c #BC1515",
+"0+ c #B66B7E",
+"a+ c #20252F",
+"b+ c #040404",
+"c+ c #0E0E0E",
+"d+ c #0B0B0B",
+"e+ c #252525",
+"f+ c #403C3B",
+"g+ c #9F5036",
+"h+ c #743B2F",
+"i+ c #1A1918",
+"j+ c #342A28",
+"k+ c #974736",
+"l+ c #FF261E",
+"m+ c #EA6B7E",
+"n+ c #713051",
+"o+ c #030303",
+"p+ c #333333",
+"q+ c #090909",
+"r+ c #BA751F",
+"s+ c #866132",
+"t+ c #9E542B",
+"u+ c #FE4821",
+"v+ c #B62000",
+"w+ c #B62018",
+"x+ c #B6727E",
+"y+ c #B64151",
+"z+ c #242424",
+"A+ c #2A2A2A",
+"B+ c #4A3211",
+"C+ c #FF6918",
+"D+ c #B64100",
+"E+ c #FF4118",
+"F+ c #FFC3A6",
+"G+ c #B60000",
+". . . . . . . . . . . . . . . . + @ . . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . + + . . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . + + . . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . + + + . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . + + + . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . + + + . . . . . . . . . . . . . ",
+". . . . . . . . . . . . . . . . # + + @ . . . # $ # . . . . . . ",
+". . . . . . . . . . . . . . . . @ + + + . . @ + + + @ . . . . . ",
+". . . . . . . . . . . . . . . . # + + + . . + + + + + . . . . . ",
+". . . . . . . . . . . . . . . . @ + + + + # + + + + + % . . . . ",
+". . . . . . . . . . . . . . . . # + + + + + + + + + + # . . . . ",
+". . . . . . + + @ . . . . . . . + + + + + + + + + + $ . . . . . ",
+". . . . . + + + + @ . . . . . . + + + + + + . + + + . . . . . . ",
+". & . . @ + + + + + * = - ; . + + + + + + + . . . . . . . . . . ",
+"& & & > + , ' ) ! + ~ { ] ^ / + + + + + + + . . . . . . . . . . ",
+"& & ( _ : < [ } | 1 2 3 4 5 + 6 + + + + + + + . . . . . . . . . ",
+"7 8 9 0 a b c d e f g h i j k l m n + + + + + . . . . . . . . . ",
+"8 7 + o p q r c s t u e u v 4 w x y z + + + + # . . . . . . . . ",
+"A B C D E F G H I J K L M I N h O P Q / # + + + . . . . . . . . ",
+"R S T U V W X i Y Z ` ...+.@.#.v $.%.. . + + + . . . . . . . . ",
+". &.*.=.-.;.;.>.,.,.'.).!.~.{.].^./.(.. . . + + # . . . . . . . ",
+". _.:.<.] 5 [.}.|.>.1.2.3.4.5.6.7.8.9.b 0.. @ + + . . . . . . . ",
+". a.b.c.%.d.g e.f.f.g.h.i.j.k.l.m.X ^.n.= . . + + . . . . . . . ",
+". o.p.q.r.s.t.u.f.v.w.x.y.z.A.B.J 8.C.r.D.. . . + @ . . . . . . ",
+". . . ; E.c F.G.H.I.J.K.>.L.M.N.O.P.= Q.R.S.. . . + . . . . . . ",
+". . . T.U.V.W.L X.K Y.Z.`.Q +Y..+++@+#+$+@ %+. . @ . . . . . . ",
+". . / p.&+*+=+-+;+r.F.>+Z.,.I H B.,+'++ + + & > %+. . . . . . . ",
+". . )+r ^ !+5 ~+{+]+^+/+(+_+r ~+]+:+<+[++ + + 7 & & . . . . . . ",
+". . / a.}+r |+U.%.1+2+3+4+d 5+6+7+}+8+9+0++ + 9 & 8 & a+. . . . ",
+". . . b+a.}+c+d+2+}+e+^+^+f+g+h+i+j+k+l+R m++ + 8 7 ( n+. . . . ",
+". . . . T.o+. . T.2+q.E.p+r.q+r+s+t+u+v+w+R x++ # 8 7 8 y+. . . ",
+". . . . . . . . . z+A+p.1+}+/ . B+C+D+C+D+E+v+F++ 7 G+7 A . . . "};
diff --git a/src/modules/url/libkviurl.cpp b/src/modules/url/libkviurl.cpp
new file mode 100644
index 00000000..16430c67
--- /dev/null
+++ b/src/modules/url/libkviurl.cpp
@@ -0,0 +1,910 @@
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 1999-2002 Andrea Parrella ([email protected])
+//
+// 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 opinion) 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 "kvi_styled_controls.h"
+#include "kvi_module.h"
+#include "libkviurl.h"
+#include "kvi_app.h"
+#include "kvi_frame.h"
+#include "kvi_kvs_eventmanager.h"
+#include "kvi_tal_popupmenu.h"
+
+#include "kvi_menubar.h"
+#include "kvi_internalcmd.h"
+#include "kvi_iconmanager.h"
+#include "kvi_action.h"
+#include "kvi_actionmanager.h"
+#include "kvi_taskbar.h"
+#include "icons.h"
+#include "kvi_pointerlist.h"
+#include <qfiledialog.h>
+#include <qmessagebox.h>
+#include <qcursor.h>
+#include <qdatetime.h>
+
+#ifdef COMPILE_USE_QT4
+ #include <q3textstream.h>
+ #include <QTextStream>
+#endif
+
+static QPixmap * g_pUrlIconPixmap = 0;
+static KviUrlAction * g_pUrlAction = 0;
+
+typedef struct _UrlDlgList
+{
+ UrlDialog *dlg;
+ int menu_id;
+} UrlDlgList;
+
+const char *g_pUrlListFilename = "/list.kviurl";
+const char *g_pBanListFilename = "/list.kviban";
+
+KviPointerList<KviUrl> *g_pList;
+KviPointerList<UrlDlgList> *g_pUrlDlgList;
+KviPointerList<KviStr> *g_pBanList;
+ConfigDialog *g_pConfigDialog;
+
+KviStr szConfigPath;
+
+void saveUrlList();
+void loadUrlList();
+void saveBanList();
+void loadBanList();
+UrlDlgList * findFrame();
+bool urllist();
+void url_module_help();
+
+
+#define KVI_URL_EXTENSION_NAME "URL module extenstion"
+
+static KviModuleExtension * url_extension_alloc(KviModuleExtensionAllocStruct * s)
+{
+ urllist();
+ return 0;
+}
+
+
+KviUrlAction::KviUrlAction(QObject * pParent)
+: KviKvsAction(pParent,
+ "url.list",
+ "url.list",
+ __tr2qs("Show URL List"),
+ __tr2qs("Shows the URL list window"),
+ KviActionManager::categoryGeneric())
+{
+ m_pBigIcon = new QPixmap(url_toolbar_xpm);
+ m_pSmallIcon = new QPixmap(url_icon_xpm);
+}
+
+KviUrlAction::~KviUrlAction()
+{
+ delete m_pBigIcon;
+ delete m_pSmallIcon;
+}
+
+QPixmap * KviUrlAction::bigIcon()
+{
+ return m_pBigIcon;
+}
+
+QPixmap * KviUrlAction::smallIcon()
+{
+ return m_pSmallIcon;
+}
+
+// ---------------------------- CLASS URLDIALOG ------------------------begin //
+
+UrlDialog::UrlDialog(KviPointerList<KviUrl> *g_pList)
+:KviWindow(KVI_WINDOW_TYPE_TOOL,g_pFrame,"URL List")
+{
+ m_pMenuBar = new KviTalMenuBar(this,"url menu");
+ m_pUrlList = new KviTalListView(this);
+ //m_pUrlList = new KviListView(this,"list");
+ KviConfig cfg(szConfigPath.ptr(),KviConfig::Read);
+
+ KviTalPopupMenu *pop;
+
+ pop = new KviTalPopupMenu(this);
+ pop->insertItem(__tr2qs("&Configure"),this,SLOT(config()));
+ pop->insertItem(__tr2qs("&Help"),this,SLOT(help()));
+ pop->insertItem(__tr2qs("Clo&se"),this,SLOT(close_slot()));
+ m_pMenuBar->insertItem(__tr2qs("&Module"),pop);
+
+ pop = new KviTalPopupMenu(this);
+ pop->insertItem(__tr2qs("&Load"),this,SLOT(loadList()));
+ pop->insertItem(__tr2qs("&Save"),this,SLOT(saveList()));
+ pop->insertItem(__tr2qs("&Clear"),this,SLOT(clear()));
+ m_pMenuBar->insertItem(__tr2qs("&List"),pop);
+
+ m_pUrlList->setShowSortIndicator(true);
+ m_pUrlList->addColumn(__tr2qs("URL"));
+ m_pUrlList->addColumn(__tr2qs("Window"));
+ m_pUrlList->addColumn(__tr2qs("Count"));
+ m_pUrlList->addColumn(__tr2qs("Timestamp"));
+
+ cfg.setGroup("colsWidth");
+ m_pUrlList->setColumnWidth(0,cfg.readIntEntry("Url",170));
+ m_pUrlList->setColumnWidth(1,cfg.readIntEntry("Window",130));
+ m_pUrlList->setColumnWidth(2,cfg.readIntEntry("Count",70));
+ m_pUrlList->setColumnWidth(3,cfg.readIntEntry("Timestamp",70));
+
+ connect(m_pUrlList,SIGNAL(doubleClicked(KviTalListViewItem *)),SLOT(dblclk_url(KviTalListViewItem *)));
+ connect(m_pUrlList,SIGNAL(rightButtonPressed(KviTalListViewItem *, const QPoint &, int)),SLOT(popup(KviTalListViewItem *, const QPoint &, int)));
+
+// setFocusHandlerNoChildren(m_pUrlList);
+#ifdef COMPILE_USE_QT4
+ m_pUrlList->setFocusPolicy(Qt::StrongFocus);
+#else
+ m_pUrlList->setFocusPolicy(QWidget::StrongFocus);
+#endif
+ m_pUrlList->setFocus();
+}
+
+void UrlDialog::config()
+{
+ if (!g_pConfigDialog) g_pConfigDialog = new ConfigDialog();
+}
+
+void UrlDialog::help()
+{
+//#warning "help"
+// m_pFrm->requestHelpOn("doc_plugin_url.kvihelp");
+}
+
+void UrlDialog::saveList()
+{
+ saveUrlList();
+}
+
+void UrlDialog::loadList()
+{
+ loadUrlList();
+}
+
+void UrlDialog::clear()
+{
+ g_pList->clear();
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) tmpitem->dlg->m_pUrlList->clear();
+ }
+}
+
+/*
+void UrlDialog::saveProperties()
+{
+
+ KviWindowProperty p;
+ p.rect = externalGeometry();
+ p.isDocked = isAttached();
+ p.splitWidth1 = 0;
+ p.splitWidth2 = 0;
+ p.timestamp = 0;
+ p.imagesVisible = 0;
+ KviWindow * w = m_pFrm->activeWindow();
+ p.isMaximized = isAttached() && w ? w->isMaximized() : isMaximized();
+ p.topSplitWidth1 = 0;
+ p.topSplitWidth2 = 0;
+ p.topSplitWidth3 = 0;
+ g_pOptions->m_pWinPropertiesList->setProperty(caption(),&p);
+}
+*/
+
+void UrlDialog::close_slot()
+{
+ close();
+}
+
+void UrlDialog::remove()
+{
+ if (!m_pUrlList->currentItem()) {
+ QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Select an URL."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+
+ for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next())
+ {
+ if (tmp->url == m_pUrlList->currentItem()->text(0)) {
+ g_pList->removeRef(tmp);
+ m_pUrlList->takeItem(m_pUrlList->currentItem());
+ return;
+ }
+ }
+}
+
+void UrlDialog::findtext()
+{
+//#warning "find text"
+/*
+ if (!m_pUrlList->currentItem()) {
+ kvirc_plugin_warning_box(__tr("Select an URL"));
+ return;
+ }
+ for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next())
+ {
+ if (tmp->url == KviStr(m_pUrlList->currentItem()->text(0))) {
+ g_pList->find(tmp);
+ KviStr ft="findtext %";
+ ft.replaceAll('%',tmp->url.ptr());
+ KviWindow *wnd = m_pFrm->findWindow(tmp->window.ptr());
+ if (wnd) {
+ if (kvirc_plugin_execute_command(wnd,ft.ptr())) {
+ if (wnd->mdiParent()) m_pFrm->m_pMdi->setTopChild(wnd->mdiParent(),true);
+ }
+ } else kvirc_plugin_warning_box(__tr("Window not found"));
+ }
+
+ }
+*/
+}
+
+void UrlDialog::dblclk_url(KviTalListViewItem *item)
+{
+ QString cmd="openurl ";
+ cmd.append(item->text(0));
+ KviKvsScript::run(cmd,this);
+}
+
+void UrlDialog::popup(KviTalListViewItem *item, const QPoint &point, int col)
+{
+ if (col == 0) {
+ m_szUrl = item->text(0);
+ KviTalPopupMenu p(0,"menu");
+ p.insertItem(__tr2qs("&Remove"),this,SLOT(remove()));
+ p.insertItem(__tr2qs("&Find Text"),this,SLOT(findtext()));
+ p.insertSeparator();
+ m_pListPopup = new KviTalPopupMenu(0,"list");
+ int i=0;
+ for(KviWindow *w=g_pFrame->windowList()->first();w;w=g_pFrame->windowList()->next()){
+ if ((w->type() <= 2) || (w->type() == 2) || (w->type() == 6)) { // values defined in kvi_define.h (console,channel,query,chat,uwindow)
+ m_pListPopup->insertItem(QString(w->plainTextCaption()),i);
+ m_pListPopup->connectItem(i,this,SLOT(sayToWin(int)));
+ i++;
+ }
+ }
+ p.insertItem(__tr2qs("&Say to Window"),m_pListPopup);
+ p.exec(QCursor::pos());
+ }
+}
+
+void UrlDialog::sayToWin(int itemID)
+{
+ KviWindow *wnd = g_pApp->findWindowByCaption(m_pListPopup->text(itemID).utf8().data());
+ QString say=QString("PRIVMSG %1 %2").arg(wnd->windowName()).arg(m_szUrl.ptr());
+ if (wnd) {
+ KviKvsScript::run(say,wnd);
+ wnd->raise();
+ wnd->setActiveWindow();
+ wnd->setFocus();
+ } else QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Window not found."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+}
+
+QPixmap *UrlDialog::myIconPtr()
+{
+ //QPixmap *icon = new QPixmap(url_icon_xpm);
+ //return icon;
+ return g_pUrlIconPixmap;
+}
+
+void UrlDialog::addUrl(QString url, QString window, QString count, QString timestamp)
+{
+ KviTalListViewItem *UrlItem = new KviTalListViewItem(m_pUrlList);
+
+ UrlItem->setText(0, url);
+ UrlItem->setText(1, window);
+ UrlItem->setText(2, count);
+ UrlItem->setText(3, timestamp);
+}
+
+void UrlDialog::resizeEvent(QResizeEvent *)
+{
+ int hght = m_pMenuBar->heightForWidth(width());
+ m_pMenuBar->setGeometry(0,0,width(),hght);
+ m_pUrlList->setGeometry(0,hght,width(),height() - hght);
+}
+
+UrlDialog::~UrlDialog()
+{
+ KviConfig cfg(szConfigPath.ptr(),KviConfig::Write);
+ cfg.setGroup("ConfigDialog");
+ if (cfg.readBoolEntry("SaveColumnWidthOnClose",false)) {
+ cfg.setGroup("ColsWidth");
+ cfg.writeEntry("Url",m_pUrlList->columnWidth(0));
+ cfg.writeEntry("Window",m_pUrlList->columnWidth(1));
+ cfg.writeEntry("Count",m_pUrlList->columnWidth(2));
+ cfg.writeEntry("Timestamp",m_pUrlList->columnWidth(3));
+ }
+
+ delete m_pUrlList;
+/* if (m_pListPopup) delete m_pListPopup;
+ m_pListPopup = 0;
+ if (m_pMenuBar) delete m_pMenuBar;
+ m_pMenuBar = 0;*/
+ UrlDlgList *tmpitem = findFrame();
+ tmpitem->dlg = 0;
+}
+
+// ----------------------------- CLASS URLDIALOG -------------------------end //
+
+// --------------------------- CLASS CONFIGDIALOG ----------------------begin //
+
+ConfigDialog::ConfigDialog()
+:QDialog()
+{
+ setCaption(__tr2qs("URL Module Configuration"));
+
+ QGridLayout *g = new QGridLayout(this,4,2,10,10);
+
+ KviConfig *cfg = new KviConfig(szConfigPath.ptr(),KviConfig::Read);
+ cfg->setGroup("ConfigDialog");
+
+ cb[0] = new KviStyledCheckBox(__tr2qs("Save URL list on module unload"),this);
+ cb[0]->setChecked(cfg->readBoolEntry("SaveUrlListOnUnload",false));
+ g->addMultiCellWidget(cb[0],0,0,0,1);
+
+ cb[1] = new KviStyledCheckBox(__tr2qs("Save columns width on URL list close"),this);
+ cb[1]->setChecked(cfg->readBoolEntry("SaveColumnWidthOnClose",false));
+ g->addMultiCellWidget(cb[1],1,1,0,1);
+
+ bool tmp = cfg->readBoolEntry("BanEnabled",false);
+ delete cfg;
+
+ m_pBanFrame = new BanFrame(this,"banlist",tmp);
+ g->addMultiCellWidget(m_pBanFrame,3,3,0,1);
+
+ QPushButton *b;
+ // configure buttons
+ b = new QPushButton(__tr2qs("&Cancel"),this,"discard");
+ connect(b,SIGNAL(clicked()),this,SLOT(discardbtn()));
+ g->addWidget(b,4,0);
+
+ b = new QPushButton(__tr2qs("&OK"),this,"accept");
+ connect(b,SIGNAL(clicked()),this,SLOT(acceptbtn()));
+ g->addWidget(b,4,1);
+
+ show();
+}
+
+void ConfigDialog::discardbtn()
+{
+ delete this;
+}
+
+void ConfigDialog::acceptbtn()
+{
+ if (m_pBanFrame) m_pBanFrame->saveBans();
+
+ KviConfig *cfg = new KviConfig(szConfigPath.ptr(),KviConfig::Write);
+ cfg->setGroup("ConfigDialog");
+ cfg->writeEntry("SaveUrlListOnUnload",cb[0]->isChecked());
+ cfg->writeEntry("SaveColumnWidthOnClose",cb[1]->isChecked());
+ delete cfg;
+
+ delete this;
+}
+
+void ConfigDialog::closeEvent(QCloseEvent *)
+{
+ delete this;
+}
+
+ConfigDialog::~ConfigDialog()
+{
+ for(int i=0;i<cbnum;i++) delete cb[i];
+ g_pConfigDialog = 0;
+}
+
+// --------------------------- CLASS CONFIGDIALOG ------------------------end //
+
+// ---------------------------- CLASS BANFRAME ------------------------begin //
+
+BanFrame::BanFrame(QWidget *parent, const char *name, bool banEnabled)
+:QFrame(parent,name)
+{
+ setFrameStyle(QFrame::Panel | QFrame::Raised);
+
+ QGridLayout *g = new QGridLayout(this,2,2,10,10);
+
+ m_pEnable = new KviStyledCheckBox(__tr2qs("Enable URL ban list"),this);
+ connect(m_pEnable,SIGNAL(clicked()),this,SLOT(enableClicked()));
+ m_pEnable->setChecked(banEnabled);
+ g->addMultiCellWidget(m_pEnable,0,0,0,1);
+
+ m_pBanList = new KviTalListBox(this);
+ m_pBanList->setMinimumHeight(100);
+ loadBanList();
+ for(KviStr *tmp=g_pBanList->first();tmp;tmp=g_pBanList->next()) m_pBanList->insertItem(tmp->ptr()); // load ban list into listbox
+ m_pBanList->setEnabled(m_pEnable->isChecked());
+ g->addMultiCellWidget(m_pBanList,1,1,0,1);
+
+ m_pAddBtn = new QPushButton(__tr2qs("&Add Ban"),this,"add");
+ connect(m_pAddBtn,SIGNAL(clicked()),this,SLOT(addBan()));
+ m_pAddBtn->setEnabled(m_pEnable->isChecked());
+ g->addWidget(m_pAddBtn,2,0);
+
+ m_pRemoveBtn = new QPushButton(__tr2qs("&Remove Selected"),this,"remove");
+ connect(m_pRemoveBtn,SIGNAL(clicked()),this,SLOT(removeBan()));
+ m_pRemoveBtn->setEnabled(m_pEnable->isChecked());
+ g->addWidget(m_pRemoveBtn,2,1);
+}
+
+void BanFrame::enableClicked()
+{
+ m_pBanList->setEnabled(m_pEnable->isChecked());
+ m_pAddBtn->setEnabled(m_pEnable->isChecked());
+ m_pRemoveBtn->setEnabled(m_pEnable->isChecked());
+}
+
+void BanFrame::addBan()
+{
+ bool ok = false;
+ KviStr *text = new KviStr(QInputDialog::getText(__tr2qs("URL Ban List"),__tr2qs("Add"),QLineEdit::Normal,QString::null,&ok,this));
+ if (ok && !text->isEmpty()) {
+ g_pBanList->append(text);
+ m_pBanList->insertItem(text->ptr());
+ }
+}
+
+void BanFrame::removeBan()
+{
+ uint i = 0;
+ while ((!m_pBanList->isSelected(i)) && (i < m_pBanList->count())) i++;
+ if (!m_pBanList->isSelected(i)) {
+ QMessageBox::warning(0,__tr2qs("Warning - KVIrc"),__tr2qs("Select a ban."),QMessageBox::Ok,QMessageBox::NoButton,QMessageBox::NoButton);
+ return;
+ }
+ KviStr item(m_pBanList->text(i).utf8().data());
+ for(KviStr *tmp=g_pBanList->first();tmp;tmp=g_pBanList->next())
+ {
+ if (*tmp == item)
+ {
+ g_pBanList->removeCurrent();
+ return;
+ }
+ }
+
+ m_pBanList->removeItem(i);
+
+}
+
+void BanFrame::saveBans()
+{
+ if (m_pEnable->isChecked()) saveBanList();
+ KviConfig *cfg = new KviConfig(szConfigPath.ptr(),KviConfig::Write);
+ cfg->setGroup("ConfigDialog");
+ cfg->writeEntry("BanEnabled",m_pEnable->isChecked());
+ delete cfg;
+}
+
+BanFrame::~BanFrame()
+{
+
+}
+
+// ---------------------------- CLASS URLTOOLBAR -------------------------end //
+
+void saveUrlList()
+{
+ QString urllist;
+ g_pApp->getLocalKvircDirectory(urllist,KviApp::ConfigPlugins);
+ urllist += g_pUrlListFilename;
+ QFile file;
+ file.setName(urllist);
+ file.open(IO_WriteOnly);
+
+ QTextStream stream(&file);
+
+ stream << g_pList->count() << endl;
+
+ for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next())
+ {
+ stream << tmp->url << endl;
+ stream << tmp->window << endl;
+ stream << tmp->count << endl;
+ stream << tmp->timestamp << endl;
+ }
+ file.flush();
+ file.close();
+}
+
+void loadUrlList()
+{
+ KviStr urllist;
+ g_pApp->getLocalKvircDirectory(urllist,KviApp::ConfigPlugins);
+ urllist += g_pUrlListFilename;
+ QFile file;
+ file.setName(QString::fromUtf8(urllist.ptr()));
+ if (!file.open(IO_ReadOnly))return;
+#ifdef COMPILE_USE_QT4
+ Q3TextStream stream(&file);
+#else
+ QTextStream stream(&file);
+#endif
+
+
+ g_pList->clear();
+
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) tmpitem->dlg->m_pUrlList->clear();
+ }
+ KviUrl *tmp;
+ int i=0;
+ int num = stream.readLine().toInt();
+ while ((!stream.eof()) && (i<num)){
+ tmp = new KviUrl();
+ tmp->url = stream.readLine();
+ tmp->window = stream.readLine();
+ tmp->count = stream.readLine().toInt();
+ tmp->timestamp = stream.readLine();
+
+ g_pList->append(tmp);
+
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) {
+ QString tmpCount;
+ tmpCount.setNum(tmp->count);
+ tmpitem->dlg->addUrl(QString(tmp->url), QString(tmp->window), tmpCount, QString(tmp->timestamp));
+ }
+ }
+ i++;
+ }
+ file.close();
+}
+
+void saveBanList()
+{
+ KviStr banlist;
+ g_pApp->getLocalKvircDirectory(banlist,KviApp::ConfigPlugins);
+ banlist += g_pBanListFilename;
+ QFile file;
+ file.setName(QString::fromUtf8(banlist.ptr()));
+ file.open(IO_WriteOnly);
+
+ QTextStream stream(&file);
+
+ stream << g_pBanList->count() << endl;
+ for(KviStr *tmp=g_pBanList->first();tmp;tmp=g_pBanList->next())
+ {
+ stream << tmp->ptr() << endl;
+ }
+ file.flush();
+ file.close();
+}
+
+void loadBanList()
+{
+ KviStr banlist;
+ g_pApp->getLocalKvircDirectory(banlist,KviApp::ConfigPlugins);
+ banlist += g_pBanListFilename;
+ QFile file;
+ file.setName(QString::fromUtf8(banlist.ptr()));
+ if (!file.open(IO_ReadOnly))return;
+#ifdef COMPILE_USE_QT4
+ Q3TextStream stream(&file);
+#else
+ QTextStream stream(&file);
+#endif
+ g_pBanList->clear();
+
+ int i=0;
+ int num = stream.readLine().toInt();
+ while ((!stream.eof()) && (i<num)){
+ KviStr *tmp = new KviStr(stream.readLine());
+ g_pBanList->append(tmp);
+ i++;
+ }
+ file.close();
+}
+
+
+/*
+ @doc: url.list
+ @type:
+ command
+ @title:
+ url.list
+ @short:
+ Opens url list
+ @syntax:
+ url.list
+ @description:
+ This command opens a window containing the urls' list.
+ In the list there is other information:[br]
+ [U]Window[/U] : window where the url has been shown last[br]
+ [U]Count[/U] : number of urls shown[br]
+ [U]Timestamp[/U] : date/time when the url has been shown first[br]
+ Clicking right on the url column of the list a menu will popup, through it
+ you can remove the selected item, find the url in the window it appeared last, and
+ say it to: [I]@Console, Channels, Querys, DCC Chats[/I] and [I]User windows[/I].[br]
+ The list is saved to file when you click on the menu item or when you unload the plugin
+ on condition that you have checked the relative checkbox in configuration dialog.[br]
+ You can also open the url in your web browser double clicking on it in the url list window.[br][br]
+
+ */
+
+static bool url_kvs_cmd_list(KviKvsModuleCommandCall * c)
+{
+ urllist();
+ return true;
+}
+
+
+UrlDlgList *findFrame()
+{
+ UrlDlgList *tmpitem = g_pUrlDlgList->first();
+ if (!tmpitem) {
+ UrlDlgList *udl = new UrlDlgList();
+ udl->dlg = 0;
+ udl->menu_id = -1;
+ g_pUrlDlgList->append(udl);
+ tmpitem = g_pUrlDlgList->current();
+ }
+ return tmpitem;
+}
+
+bool urllist()
+{
+ UrlDlgList *tmpitem = findFrame();
+ if (tmpitem->dlg) return false;
+
+ tmpitem->dlg = new UrlDialog(g_pList);
+ g_pFrame->addWindow(tmpitem->dlg);
+
+ for(KviUrl *tmp=g_pList->first();tmp;tmp=g_pList->next())
+ {
+ QString tmpCount;
+ tmpCount.setNum(tmp->count);
+ tmpitem->dlg->addUrl(QString(tmp->url), QString(tmp->window), tmpCount, QString(tmp->timestamp));
+ }
+ return true;
+}
+
+
+/*
+ @doc: url.config
+ @type:
+ command
+ @title:
+ url.config
+ @short:
+ Loads URL list module
+ @syntax:
+ url.config
+ @description:
+ This command opens a configuration window where it is possible
+ to setup plugin's parameters. You can also open this window by
+ using popup menu in the url list window or by clicking on the "configure plugin" button
+ in plugins options.<BR><BR>
+ <H3>Configure dialog options:</H3>
+ There is also a ban list widget, which allows to have a list of words that plugin mustn't catch.<BR><BR>
+ <I>E.g.<BR>
+ <blockquote>if the word "ftp" is inserted in the ban list and if in a window there is an output like "ftp.kvirc.net",
+ the url will not be catched.</blockquote></I>
+ <HR>
+ */
+
+static bool url_kvs_cmd_config(KviKvsModuleCommandCall * c)
+{
+ if (!g_pConfigDialog) g_pConfigDialog = new ConfigDialog();
+ return true;
+}
+
+int check_url(KviWindow *w,const QString &szUrl) // return 0 if no occurence of the url were found
+{
+ int tmp = 0;
+
+ for(KviStr *tmpi=g_pBanList->first();tmpi;tmpi=g_pBanList->next())
+ {
+ if (szUrl.find(QString(tmpi->ptr())) != -1) tmp++;
+ }
+ if (tmp > 0) return tmp;
+
+ for(KviUrl *u = g_pList->first();u;u=g_pList->next())
+ {
+ if (u->url == szUrl) {
+ u->window = w->plainTextCaption();
+ u->count++;
+ tmp++;
+ }
+ }
+
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) {
+ KviTalListViewItemIterator lvi(tmpitem->dlg->m_pUrlList);
+ for(;lvi.current();++lvi)
+ {
+ if (lvi.current()->text(0) == szUrl) {
+ int tmpCount = lvi.current()->text(2).toInt();
+ tmpCount++;
+ QString tmpStr;
+ tmpStr.setNum(tmpCount);
+ lvi.current()->setText(2,tmpStr);
+ lvi.current()->setText(1,w->plainTextCaption());
+ }
+ }
+ }
+ }
+ return tmp;
+}
+
+bool urllist_module_event_onUrl(KviKvsModuleEventCall * c)
+{
+ KviKvsVariant * vUrl = c->firstParam();
+ QString szUrl;
+ if(vUrl)vUrl->asString(szUrl);
+
+ if (check_url(c->window(),szUrl) == 0)
+ {
+
+ KviUrl *tmp = new KviUrl;
+ KviStr tmpTimestamp;
+ QDate d = QDate::currentDate();
+ KviStr date(KviStr::Format,"%d-%d%d-%d%d",d.year(),d.month() / 10,d.month() % 10,d.day() / 10,d.day() % 10);
+ tmpTimestamp = "["+date+"]"+" [";
+ tmpTimestamp += QTime::currentTime().toString()+"]";
+ tmp->url = szUrl;
+ tmp->window = c->window()->plainTextCaption();
+ tmp->count = 1;
+ tmp->timestamp = tmpTimestamp;
+
+ g_pList->append(tmp);
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) {
+ QString tmpCount;
+ tmpCount.setNum(tmp->count);
+ tmpitem->dlg->addUrl(QString(tmp->url), QString(tmp->window), tmpCount, QString(tmp->timestamp));
+ tmpitem->dlg->taskBarItem()->highlight(false);
+ }
+ }
+ }
+ return true;
+}
+
+
+/* @doc: url.load
+ @type:
+ command
+ @title:
+ url.load
+ @short:
+ Loads URL list module
+ @syntax:
+ url.load
+ @description:
+ Loads the URL list module which keeps track of all urls shown in kvirc windows.
+*/
+
+
+static bool url_module_init(KviModule *m)
+{
+ KviModuleExtensionDescriptor * d = m->registerExtension("tool",
+ KVI_URL_EXTENSION_NAME,
+ __tr2qs("View URL list"),
+ url_extension_alloc);
+ if(d)d->setIcon(*(g_pIconManager->getSmallIcon(KVI_SMALLICON_URL)));
+
+ g_pList = new KviPointerList<KviUrl>;
+ g_pList->setAutoDelete(true);
+
+ g_pUrlDlgList = new KviPointerList<UrlDlgList>;
+ g_pUrlDlgList->setAutoDelete(true);
+
+ g_pBanList = new KviPointerList<KviStr>;
+ g_pBanList->setAutoDelete(true);
+
+ g_pUrlIconPixmap = new QPixmap(url_icon_xpm);
+
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"list",url_kvs_cmd_list);
+ KVSM_REGISTER_SIMPLE_COMMAND(m,"config",url_kvs_cmd_config);
+ g_pUrlAction = new KviUrlAction(KviActionManager::instance());
+ KviActionManager::instance()->registerAction(g_pUrlAction);
+
+ m->kvsRegisterAppEventHandler(KviEvent_OnUrl,urllist_module_event_onUrl);
+
+ g_pApp->getLocalKvircDirectory(szConfigPath,KviApp::ConfigPlugins,"url.conf");
+
+ loadUrlList();
+ loadBanList();
+
+ UrlDlgList *udl = new UrlDlgList();
+ udl->dlg = 0;
+ g_pUrlDlgList->append(udl);
+
+ return true;
+}
+
+static bool url_module_cleanup(KviModule *m)
+{
+ KviConfig cfg(szConfigPath.ptr(),KviConfig::Read);
+ cfg.setGroup("ConfigDialog");
+ if (cfg.readBoolEntry("SaveUrlListOnUnload",false) == true) saveUrlList();
+ for (UrlDlgList *tmpitem=g_pUrlDlgList->first();tmpitem;tmpitem=g_pUrlDlgList->next()) {
+ if (tmpitem->dlg) tmpitem->dlg->close();
+ }
+
+ delete g_pList;
+ g_pList = 0;
+ delete g_pBanList;
+ g_pBanList = 0;
+
+ delete g_pUrlDlgList;
+ g_pUrlDlgList = 0;
+ delete g_pUrlAction;
+ g_pUrlAction = 0;
+
+
+ delete g_pUrlIconPixmap;
+ g_pUrlIconPixmap = 0;
+
+ return true;
+}
+
+static bool url_module_can_unload(KviModule *m)
+{
+ // FIXME: really ugly :/
+ return false;
+}
+
+void url_module_config()
+{
+ if (!g_pConfigDialog) g_pConfigDialog = new ConfigDialog();
+}
+
+/*
+ @doc: url
+ @type:
+ module
+ @short:
+ The URL list module: keeps track of all urls shown in kvirc windows
+ @title:
+ The URL list module
+ @body:
+ This plugin keeps track of all urls shown in kvirc windows.
+ <H3>Exported commands:</H3>
+ <B>/url.list</B> : this command opens a window containing the urls' list.
+ In the list there is other information:<BR>
+ <U>Window</U> : window where the url has been shown last<BR>
+ <U>Count</U> : number of urls shown<BR>
+ <U>Timestamp</U> : date/time when the url has been shown first<BR>
+ Clicking right on the url column of the list a menu will popup, through it
+ you can remove the selected item, find the url in the window it appeared last, and
+ say it to: <I>@Console, Channels, Querys, DCC Chats</I> and <I>User windows</I>.<BR>
+ The list is saved to file when you click on the menu item or when you unload the plugin
+ on condition that you have checked the relative checkbox in configuration dialog.<BR>
+ You can also open the url in your web browser double clicking on it in the url list window.<BR><BR>
+
+ Mail me if you have any suggestion or you want to notice a bug.<BR>
+ <B>Andrea 'YaP' Parrella</B> &lt;[email protected]&gt;<BR><BR>
+ Thanks to:<BR>
+ <B>Szymon Stefanek</B> and <B>Till Bush</B> for their help.<BR>
+ <B>Ted Podgurski</B> for toolbar's icons.
+*/
+
+
+KVIRC_MODULE(
+ "URL",
+ "1.0.0" ,
+ "Copyright (C) 2002 Andrea Parrella <[email protected]>" ,
+ "url list module for KVIrc",
+ url_module_init,
+ url_module_can_unload,
+ 0,
+ url_module_cleanup
+)
+
+#include "libkviurl.moc"
diff --git a/src/modules/url/libkviurl.h b/src/modules/url/libkviurl.h
new file mode 100644
index 00000000..05d56ce8
--- /dev/null
+++ b/src/modules/url/libkviurl.h
@@ -0,0 +1,144 @@
+#ifndef _H_URLDLG
+#define _H_URLDLG
+
+//
+// This file is part of the KVIrc irc client distribution
+// Copyright (C) 1999-2000 Andrea Parrella ([email protected])
+//
+// 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 opinion) 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 <qdialog.h>
+#include <qlayout.h>
+#include "kvi_tal_listview.h"
+#include <qstring.h>
+#include <qpushbutton.h>
+#include <qfile.h>
+#ifdef COMPILE_USE_QT4
+ #include <q3textstream.h>
+#else
+ #include <qtextstream.h>
+#endif
+#include <qcheckbox.h>
+#include "kvi_tal_listbox.h"
+#include <qmenubar.h>
+#include <qinputdialog.h>
+#include <qtoolbutton.h>
+#include <qiconset.h>
+
+#include "kvi_locale.h"
+#include "kvi_config.h"
+#include "kvi_irctoolbar.h"
+#include "kvi_imagelib.h"
+#include "kvi_window.h"
+#include "kvi_tal_menubar.h"
+#include "kvi_mextoolbar.h"
+#include "kvi_styled_controls.h"
+
+#include <qpixmap.h>
+
+typedef struct _KviUrl
+{
+ QString url;
+ QString window;
+ int count;
+ QString timestamp;
+} KviUrl;
+
+
+class UrlDialog : public KviWindow
+{
+ Q_OBJECT
+public:
+ UrlDialog(KviPointerList<KviUrl> *g_pList);
+ ~UrlDialog();
+private:
+ KviTalMenuBar *m_pMenuBar;
+ KviTalPopupMenu *m_pListPopup; // dynamic popup menu
+ KviStr m_szUrl; // used to pass urls to sayToWin slot
+protected:
+ QPixmap *myIconPtr();
+ void resizeEvent(QResizeEvent *);
+public:
+ KviTalListView *m_pUrlList;
+ void addUrl(QString url, QString window, QString count, QString timestamp);
+// void saveProperties();
+protected slots:
+ void config();
+ void help();
+ void saveList();
+ void loadList();
+ void clear();
+ void close_slot();
+ void remove();
+ void findtext();
+ void dblclk_url(KviTalListViewItem *item);
+ void popup(KviTalListViewItem *item, const QPoint &p, int col);
+ void sayToWin(int);
+};
+
+class BanFrame : public QFrame
+{
+ Q_OBJECT
+public:
+ BanFrame(QWidget *parent=0, const char *name=0, bool banEnable = false);
+ ~BanFrame();
+ void saveBans();
+private:
+ KviStyledCheckBox *m_pEnable;
+ KviTalListBox *m_pBanList;
+ QPushButton *m_pAddBtn;
+ QPushButton *m_pRemoveBtn;
+protected slots:
+ void enableClicked();
+ void addBan();
+ void removeBan();
+};
+
+#define cbnum 2
+
+class ConfigDialog : public QDialog
+{
+ Q_OBJECT
+public:
+ ConfigDialog();
+ ~ConfigDialog();
+private:
+ KviStyledCheckBox *cb[cbnum];
+ BanFrame *m_pBanFrame;
+ void closeEvent(QCloseEvent *);
+protected slots:
+ void acceptbtn();
+ void discardbtn();
+};
+
+#include "kvi_kvs_action.h"
+
+class KviUrlAction : public KviKvsAction
+{
+ Q_OBJECT
+public:
+ KviUrlAction(QObject * pParent);
+ ~KviUrlAction();
+protected:
+ QPixmap * m_pBigIcon;
+ QPixmap * m_pSmallIcon;
+public:
+ virtual QPixmap * bigIcon();
+ virtual QPixmap * smallIcon();
+};
+
+#endif