From bcb704366cb5e333a626c18c308c7e0448a8e69f Mon Sep 17 00:00:00 2001 From: toma Date: Wed, 25 Nov 2009 17:56:58 +0000 Subject: Copy the KDE 3.5 branch to branches/trinity for new KDE 3.5 features. BUG:215923 git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/kdenetwork@1054174 283d02a7-25f6-0310-bc7c-ecb5cbfe19da --- kopete/plugins/webpresence/DESIGN | 12 + kopete/plugins/webpresence/Makefile.am | 27 ++ kopete/plugins/webpresence/TODO | 5 + .../plugins/webpresence/kopete_webpresence.desktop | 120 ++++++ .../webpresence/kopete_webpresence_config.desktop | 116 +++++ kopete/plugins/webpresence/webpresence_html.xsl | 140 ++++++ .../webpresence/webpresence_html_images.xsl | 59 +++ kopete/plugins/webpresence/webpresence_xhtml.xsl | 139 ++++++ .../webpresence/webpresence_xhtml_images.xsl | 60 +++ kopete/plugins/webpresence/webpresenceplugin.cpp | 473 +++++++++++++++++++++ kopete/plugins/webpresence/webpresenceplugin.h | 123 ++++++ .../plugins/webpresence/webpresencepreferences.cpp | 64 +++ .../plugins/webpresence/webpresencepreferences.h | 50 +++ kopete/plugins/webpresence/webpresenceprefs.ui | 369 ++++++++++++++++ 14 files changed, 1757 insertions(+) create mode 100644 kopete/plugins/webpresence/DESIGN create mode 100644 kopete/plugins/webpresence/Makefile.am create mode 100644 kopete/plugins/webpresence/TODO create mode 100644 kopete/plugins/webpresence/kopete_webpresence.desktop create mode 100644 kopete/plugins/webpresence/kopete_webpresence_config.desktop create mode 100644 kopete/plugins/webpresence/webpresence_html.xsl create mode 100644 kopete/plugins/webpresence/webpresence_html_images.xsl create mode 100644 kopete/plugins/webpresence/webpresence_xhtml.xsl create mode 100644 kopete/plugins/webpresence/webpresence_xhtml_images.xsl create mode 100644 kopete/plugins/webpresence/webpresenceplugin.cpp create mode 100644 kopete/plugins/webpresence/webpresenceplugin.h create mode 100644 kopete/plugins/webpresence/webpresencepreferences.cpp create mode 100644 kopete/plugins/webpresence/webpresencepreferences.h create mode 100644 kopete/plugins/webpresence/webpresenceprefs.ui (limited to 'kopete/plugins/webpresence') diff --git a/kopete/plugins/webpresence/DESIGN b/kopete/plugins/webpresence/DESIGN new file mode 100644 index 00000000..d62c9c34 --- /dev/null +++ b/kopete/plugins/webpresence/DESIGN @@ -0,0 +1,12 @@ +Kopete Web Presence Plugin + +What It Does +Provides a view of the current state of your contact list as a webpage. + +How It Does It +Every so often, it writes a file containing a snapshot of who is online and who is not in your contactlist to a location you specify. This can be a local file, an FTP server, a HTTP server, or anywhere else that KIO can access. + +Use KIO::NetAccess to upload the files! + +Getting Info about Local User's Status +Goal is to allow ppl who don't have us on their contactlist to see what our current status is and what our UIN/id is for each protocol. So we need to know (protocol, uin, status). diff --git a/kopete/plugins/webpresence/Makefile.am b/kopete/plugins/webpresence/Makefile.am new file mode 100644 index 00000000..7f859379 --- /dev/null +++ b/kopete/plugins/webpresence/Makefile.am @@ -0,0 +1,27 @@ +METASOURCES = AUTO + +AM_CPPFLAGS = $(KOPETE_INCLUDES) $(all_includes) $(LIBXML_CFLAGS) $(LIBXSLT_CFLAGS) + +kde_module_LTLIBRARIES = kopete_webpresence.la kcm_kopete_webpresence.la + +kopete_webpresence_la_SOURCES = webpresenceplugin.cpp + +kopete_webpresence_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries) +kopete_webpresence_la_LIBADD = ../../libkopete/libkopete.la $(LIBXML_LIBS) $(LIBXSLT_LIBS) + +kcm_kopete_webpresence_la_SOURCES = webpresencepreferences.cpp webpresenceprefs.ui +kcm_kopete_webpresence_la_LDFLAGS = -module -no-undefined $(KDE_PLUGIN) $(all_libraries) +kcm_kopete_webpresence_la_LIBADD = ../../libkopete/libkopete.la $(LIB_KUTILS) + +service_DATA = kopete_webpresence.desktop +servicedir = $(kde_servicesdir) + +kcm_DATA = kopete_webpresence_config.desktop +kcmdir = $(kde_servicesdir)/kconfiguredialog + +mydata_DATA = webpresence_html.xsl\ + webpresence_html_images.xsl\ + webpresence_xhtml.xsl\ + webpresence_xhtml_images.xsl +mydatadir = $(kde_datadir)/kopete/webpresence +EXTRA_DIST = $(mydata_DATA) diff --git a/kopete/plugins/webpresence/TODO b/kopete/plugins/webpresence/TODO new file mode 100644 index 00000000..28b78c3c --- /dev/null +++ b/kopete/plugins/webpresence/TODO @@ -0,0 +1,5 @@ +1) Investigate how to include the plugin's output server side to give users a start. +1a) XSLT processing? + +2) Icon + diff --git a/kopete/plugins/webpresence/kopete_webpresence.desktop b/kopete/plugins/webpresence/kopete_webpresence.desktop new file mode 100644 index 00000000..85068ce2 --- /dev/null +++ b/kopete/plugins/webpresence/kopete_webpresence.desktop @@ -0,0 +1,120 @@ +[Desktop Entry] +Type=Service +X-Kopete-Version=1000900 +Icon=html +ServiceTypes=Kopete/Plugin +X-KDE-Library=kopete_webpresence +X-KDE-PluginInfo-Author=Will Stephenson +X-KDE-PluginInfo-Email=will@stevello.free-online.co.uk +X-KDE-PluginInfo-Name=kopete_webpresence +X-KDE-PluginInfo-Version=0.8.0 +X-KDE-PluginInfo-Website=http://www.cs.ncl.ac.uk/old/people/william.stephenson +X-KDE-PluginInfo-Category=Plugins +X-KDE-PluginInfo-Depends= +X-KDE-PluginInfo-License=GPL +X-KDE-PluginInfo-EnabledByDefault=false +Comment=Show the status of (parts of) your contact list on a webpage +Comment[ar]=يظهر حالة أجزاء من قائمة أتصالاتك على صفحة الشبكة +Comment[be]=Паказвае спіс кантактаў ці яго частку на старонцы Сеціва +Comment[bg]=Приставка за показвана състоянието на (част от) списъка с контакти като уеб страница +Comment[bn]=একটি ওয়েবপেজে আপনার যোগাযোগ তালিকার (এর অংশের) অবস্থা প্রদর্শন করে +Comment[bs]=Pokazuje status (dijelova) vaše kontakt liste na web stranici +Comment[ca]=Mostra l'estatus de (parts de) la vostra llista de contactes a una pàgina web +Comment[cs]=Zobrazí stav (části) seznamu kontaktů na webu +Comment[cy]=Dangos cyflwr o (rannau o) eich rhestr cysylltiadau ar dudalen wê +Comment[da]=Vis status for (dele af) din kontaktliste på en netside +Comment[de]=Zeigt den Status (von Teilen) der eigenen Kontaktliste auf einer Internetseite +Comment[el]=Εμφάνιση της κατάστασης της λίστας επαφών σας σε ιστοσελίδα +Comment[es]=Mostrar el estado de (partes de) su lista de contactos en una página web +Comment[et]=Näitab (vähemalt osa) kontaktide staatust veebileheküljel +Comment[eu]=Erakutsi zure kontaktu zerrendaren (edo zati baten) egoera web orri batean +Comment[fa]=وضعیت )اجزایی از( فهرست تماس شما را روی صفحۀ وب نمایش می‌دهد +Comment[fi]=Näytä kontaktien tila www-sivulla +Comment[fr]=Affiche l'état de connexion de votre liste (ou d'une partie) sur une page internet +Comment[gl]=Mostra o status da túa lista de contactos (ou parte) nunha páxina web +Comment[he]=מציא את מצב ההתחברות של חברים ברשימת הקשר שלך )או של חלקם( בעמוד WEB. +Comment[hi]=वेब पृष्ठ पर आपकी सम्पर्क सूची की स्थिति (या आंशिक) दिखाए +Comment[hr]=Prikazivanje statusa (dijelova) vaše liste kontakata na web stranici +Comment[hu]=A partnerlista-tagok állapotának megjelenítése weboldalon +Comment[is]=Sýnir stöðu (hluta) lista þinna á vefsíðu +Comment[it]=Mostra lo stato della (o parte della) tua lista contatti su una pagina web +Comment[ja]=コンタクトリスト (の一部) の状態をウェブページに表示 +Comment[ka]=სტატუსის ვებ გვერდზე ჩვენება +Comment[kk]=Контакттарыңыздың тізімінің (не оның бөлігінің) күйін веб парақта көрсетеді +Comment[km]=បង្ហាញ​ស្ថានភាព (ផ្នែក) នៃ​បញ្ជី​ទំនាក់​ទំនង​របស់​អ្នក​នៅ​លើ​ទំព័រ​វ៉េប +Comment[lt]=Rodyti kontaktų sąrašo (sąrašo dalies) būklę internetiniame puslapyje +Comment[mk]=Го прикажува статусот на (деловите на) вашата листа со контакти на вебстраница +Comment[nb]=Vis tilstanden til (deler av) kontaktlista de på en nettside +Comment[nds]=Wiest den Status (vun en poor) vun Dien Kontakten op en Nettsiet +Comment[ne]=वेबपृष्ठमा तपाईँको सम्पर्क सूची (भागको) वस्तुस्थिति देखाउनुहोस् +Comment[nl]=Toont de status van (delen van) uw contactenlijst op een webpagina +Comment[nn]=Vis tilstanden til (delar av) kontaktlista på ei nettside +Comment[pl]=Pokazuje status (części) Twojej listy kontaktów na stronie WWW +Comment[pt]=Mostra o estado (de partes) da sua lista de contactos numa página Web +Comment[pt_BR]=Mostra o status de (ou parte de) sua lista de contatos em uma página web +Comment[ru]=Отображает состояние вашего списка контактов (или его части) на странице в Сети +Comment[sk]=Zobrazenie stavu (časti) zo zoznamu kontaktov na webovej stránke +Comment[sl]=Pokaže stanje (dela) vašega seznama stikov na spletni strani +Comment[sr]=Приказивање статуса (делова) ваше листе контаката на веб страници +Comment[sr@Latn]=Prikazivanje statusa (delova) vaše liste kontakata na veb stranici +Comment[sv]=Visa status för (delar av) din kontaktlista på en webbsida +Comment[ta]=இணைய பக்கத்தில் உங்கள் தொடர்பாளரின் நிலைப்பட்டியலை காட்டு +Comment[tg]=Ҳолати (қисме аз) рӯйхати пайвастшавии шуморо дар саҳифаи шабака нишон медиҳад +Comment[tr]=Bağlantı listesinde web sayfası olanların (bölümler) durumunu göster +Comment[uk]=Показує стан вашого списку контактів (або його частини) на сторінці у Тенетах +Comment[zh_CN]=在网页上显示您联系人的状态 +Comment[zh_HK]=在網頁上顯示您(一部份)聯絡人清單的狀態 +Comment[zh_TW]=在網頁上顯示(部份)您的聯絡人的狀態 +Name=Web Presence +Name[ar]=موقع على الشبكة +Name[be]=Сеціўная прысутнасць +Name[bg]=Уеб присъствие +Name[bn]=ওয়েব উপস্থিতি +Name[bs]=Web prisustvo +Name[ca]=Web de presència +Name[cs]=Přítomnost na webu +Name[cy]=Presenoldeb Gwê +Name[da]=WWW-nærvær +Name[de]=Web-Präsenz +Name[el]=Παρουσία σε ιστοσελίδα +Name[eo]=TTT-Prezenco +Name[es]=Presencia Web +Name[et]=Veebinimekiri +Name[fa]=حضور وب +Name[fi]=WWW-paikallaolo +Name[fr]=Présence sur le web +Name[gl]=Presencia na web +Name[he]=נוכחות רשת +Name[hi]=वेब उपस्थिति +Name[hr]=Prisutnost na webu +Name[hu]=Webes jelenlét +Name[is]=Á vefnum +Name[it]=Presenza web +Name[ja]=ウェブプレゼンス +Name[ka]=ვებ თვისებები +Name[kk]=Вебте қатысу +Name[km]=វត្តមាន​វ៉េប +Name[lt]=Rodyti internete +Name[mk]=Присуство на веб +Name[nb]=Profil på nettet +Name[nds]=Nett-Praatschap +Name[ne]=वेब उपस्थिति +Name[nl]=Web-aanwezigheid +Name[nn]=Profil på nettet +Name[pl]=Status na WWW +Name[pt]=Presença na Web +Name[pt_BR]=Presença Web +Name[ro]=Prezenţă Web +Name[ru]=Присутствие в Сети +Name[sk]=Prítomnosť na webe +Name[sl]=Spletna prisotnost +Name[sr]=Присутност на Вебу +Name[sr@Latn]=Prisutnost na Vebu +Name[sv]=Webbnärvaro +Name[ta]=இணைய இருப்பு +Name[tg]=Мавҷудияти Web +Name[tr]=Web Hazır Bulunması +Name[uk]=Присутність у Тенет +Name[zh_CN]=Web 状态 +Name[zh_HK]=網上狀態 +Name[zh_TW]=網頁連線 diff --git a/kopete/plugins/webpresence/kopete_webpresence_config.desktop b/kopete/plugins/webpresence/kopete_webpresence_config.desktop new file mode 100644 index 00000000..a714d602 --- /dev/null +++ b/kopete/plugins/webpresence/kopete_webpresence_config.desktop @@ -0,0 +1,116 @@ +[Desktop Entry] +Type=Service +Icon=html +ServiceTypes=KCModule + +X-KDE-ModuleType=Library +X-KDE-Library=kopete_webpresence +X-KDE-FactoryName=WebPrecencePreferencesFactory +X-KDE-ParentApp=kopete_webpresence +X-KDE-ParentComponents=kopete_webpresence + +Comment=Show the status of (parts of) your contact list on a web page +Comment[ar]=يظهر حالة أجزاء من قائمة أتصالاتك على الشبكة +Comment[be]=Паказвае стан спіса кантактаў ці яго часткі на старонцы Сеціва +Comment[bg]=Приставка за показвана състоянието на (част от) списъка с контакти като уеб страница +Comment[bn]=একটি ওয়েবপেজে আপনার যোগাযোগ তালিকার (এর অংশের) অবস্থা প্রদর্শন করে +Comment[bs]=Pokazuje status (dijelova) vaše kontakt liste na web stranici +Comment[ca]=Mostra l'estatus de (parts de) la vostra llista de contactes sobre una pàgina web +Comment[cs]=Zobrazí stav (části) seznamu kontaktů na webu +Comment[cy]=Dangos cyflwr o (rannau o) eich rhestr cysylltiadau ar dudalen wê +Comment[da]=Vis status for (dele af) din kontaktliste på en netside +Comment[de]=Zeigt den Status (von Teilen) der eigenen Kontaktliste auf einer Internetseite +Comment[el]=Εμφάνιση της κατάστασης της λίστας επαφών σας σε ιστοσελίδα +Comment[es]=Mostrar el estado de (partes de) su lista de contactos en una página web +Comment[et]=Näitab (vähemalt osa) kontaktide staatust veebileheküljel +Comment[eu]=Erakutsi zure kontaktu zerrendaren (edo zati baten) egoera web orri batean +Comment[fa]=وضعیت )اجزایی از( فهرست تماس شما را روی صفحۀ وب نمایش می‌دهد +Comment[fi]=Näytä kontaktien tila www-sivulla +Comment[fr]=Afficher l'état de connexion de votre liste (ou d'une partie) sur une page internet +Comment[gl]=Amosar o estado da (parte da) súa lista de contactos nunha páxina web +Comment[he]=מציא את מצב ההתחברות של חברים ברשימת הקשר שלך )או של חלקם( בעמוד WEB. +Comment[hi]=वेब पृष्ठ पर आपकी सम्पर्क सूची की स्थिति (या आंशिक) दिखाए +Comment[hr]=Prikazivanje statusa (dijelova) vaše liste kontakata na web stranici +Comment[hu]=A partnerek állapotának megjelenítése weboldalon +Comment[is]=Sýnir stöðu (hluta) lista þinna á vefsíðu +Comment[it]=Mostra lo stato (o una parte) della tua lista contatti su una pagina web +Comment[ja]=コンタクトリスト (の一部) の状態をウェブページに表示 +Comment[ka]=სტატუსის ვებ გვერდზე ჩვენება +Comment[kk]=Контакттарыңыздың тізімінің (не оның бөлігінің) күйін веб парақта көрсетеді +Comment[km]=បង្ហាញ​ស្ថានភាព (ផ្នែក) នៃ​បញ្ជី​ទំនាក់​ទំនង​របស់​អ្នក​នៅ​លើ​ទំព័រ​វ៉េប +Comment[lt]=Rodyti kontaktų sąrašo (sąrašo dalies) būklę internetiniame puslapyje +Comment[mk]=Го прикажува статусот на (деловите на) вашата листа со контакти на вебстраница +Comment[nb]=Vis tilstanden til (deler av) kontaktlista de på en nettside +Comment[nds]=Wiest den Status (vun en poor) vun Dien Kontakten op en Nettsiet +Comment[ne]=वेबपृष्ठमा तपाईँको सम्पर्क सूची (भागको) वस्तुस्थिति देखाउनुहोस् +Comment[nl]=Toont de status van (delen van) uw contactenlijst op een webpagina +Comment[nn]=Vis tilstanden til (delar av) kontaktlista på ei nettside +Comment[pl]=Pokazuje status (części) Twojej listy kontaktów na stronie WWW +Comment[pt]=Mostra o estado (de partes) da sua lista de contactos numa página Web +Comment[pt_BR]=Mostra o status de (ou parte de) sua lista de contatos em uma página web +Comment[ru]=Отображает состояние вашего списка контактов (или его части) на странице в Сети +Comment[sk]=Zobrazenie stavu (časti) zo zoznamu kontaktov na webovej stránke +Comment[sl]=Pokaže stanje (dela) vašega seznama stikov na spletni strani +Comment[sr]=Приказивање статуса (делова) ваше листе контаката на веб страници +Comment[sr@Latn]=Prikazivanje statusa (delova) vaše liste kontakata na veb stranici +Comment[sv]=Visa status för (delar av) din kontaktlista på en webbsida +Comment[ta]=இணைய பக்கத்தில் உங்கள் தொடர்பாளர் நிலைப்பட்டியலை காட்டு +Comment[tg]=Ҳолати (қисме аз) рӯйхати пайвастшавии шуморо дар саҳифаи шабака нишон медиҳад +Comment[tr]=Bağlantı listesinde web sayfası olanların (bölümler) durumunu göster +Comment[uk]=Показує стан вашого списку контактів (або його частини) на сторінці у Тенетах +Comment[zh_CN]=在网页上显示您联系人的状态 +Comment[zh_HK]=在網頁上顯示您(一部份)聯絡人清單的狀態 +Comment[zh_TW]=在網頁上顯示(部份)您的聯絡人的狀態 +Name=Web Presence +Name[ar]=موقع على الشبكة +Name[be]=Сеціўная прысутнасць +Name[bg]=Уеб присъствие +Name[bn]=ওয়েব উপস্থিতি +Name[bs]=Web prisustvo +Name[ca]=Web de presència +Name[cs]=Přítomnost na webu +Name[cy]=Presenoldeb Gwê +Name[da]=WWW-nærvær +Name[de]=Web-Präsenz +Name[el]=Παρουσία σε ιστοσελίδα +Name[eo]=TTT-Prezenco +Name[es]=Presencia Web +Name[et]=Veebinimekiri +Name[fa]=حضور وب +Name[fi]=WWW-paikallaolo +Name[fr]=Présence sur le web +Name[gl]=Presencia na web +Name[he]=נוכחות רשת +Name[hi]=वेब उपस्थिति +Name[hr]=Prisutnost na webu +Name[hu]=Webes jelenlét +Name[is]=Á vefnum +Name[it]=Presenza web +Name[ja]=ウェブプレゼンス +Name[ka]=ვებ თვისებები +Name[kk]=Вебте қатысу +Name[km]=វត្តមាន​វ៉េប +Name[lt]=Rodyti internete +Name[mk]=Присуство на веб +Name[nb]=Profil på nettet +Name[nds]=Nett-Praatschap +Name[ne]=वेब उपस्थिति +Name[nl]=Web-aanwezigheid +Name[nn]=Profil på nettet +Name[pl]=Status na WWW +Name[pt]=Presença na Web +Name[pt_BR]=Presença Web +Name[ro]=Prezenţă Web +Name[ru]=Присутствие в Сети +Name[sk]=Prítomnosť na webe +Name[sl]=Spletna prisotnost +Name[sr]=Присутност на Вебу +Name[sr@Latn]=Prisutnost na Vebu +Name[sv]=Webbnärvaro +Name[ta]=இணைய இருப்பு +Name[tg]=Мавҷудияти Web +Name[tr]=Web Hazır Bulunması +Name[uk]=Присутність у Тенет +Name[zh_CN]=Web 状态 +Name[zh_HK]=網上狀態 +Name[zh_TW]=網頁連線 diff --git a/kopete/plugins/webpresence/webpresence_html.xsl b/kopete/plugins/webpresence/webpresence_html.xsl new file mode 100644 index 00000000..f768ccf5 --- /dev/null +++ b/kopete/plugins/webpresence/webpresence_html.xsl @@ -0,0 +1,140 @@ + + + + + + + + + + + My IM Status + + +

+ +
+ + Last update at: + + + + +
+ + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + AIM + + + MSN + + + ICQ + + + Jabber + + + Yahoo + + + Gadu-Gadu + + + WinPopup + + + SMS + + + IRC + + + Unknown + + + + + + + + + + + + + + + + + + + + + + ( + + + + + : + + + + + + + ) + + + + + + + + ( + + ) + + + + + + + + +
+ + diff --git a/kopete/plugins/webpresence/webpresence_html_images.xsl b/kopete/plugins/webpresence/webpresence_html_images.xsl new file mode 100644 index 00000000..5b707046 --- /dev/null +++ b/kopete/plugins/webpresence/webpresence_html_images.xsl @@ -0,0 +1,59 @@ + + + + + + + + + + + + images + + + + + MSN + + + ICQ + + + Jabber + + + Yahoo + + + AIM + + + IRC + + + SMS + + + Gadu-Gadu + + + WinPopup + + + + + + + diff --git a/kopete/plugins/webpresence/webpresence_xhtml.xsl b/kopete/plugins/webpresence/webpresence_xhtml.xsl new file mode 100644 index 00000000..9d749c14 --- /dev/null +++ b/kopete/plugins/webpresence/webpresence_xhtml.xsl @@ -0,0 +1,139 @@ + + + + + + + + + + + My IM Status + + +

+ +
+

+ Last update at: + +

+ + +
+ + + + + + + + + + + +
+ + + + + + + +
+
+ + + + + AIM + + + MSN + + + ICQ + + + Jabber + + + Yahoo + + + Gadu-Gadu + + + WinPopup + + + SMS + + + IRC + + + Unknown + + + + + + + + + + + + + + + + + + + + + + ( + + + + + : + + + + + + + ) + + + + + + + + ( + + ) + + + + + + + + +
+ + diff --git a/kopete/plugins/webpresence/webpresence_xhtml_images.xsl b/kopete/plugins/webpresence/webpresence_xhtml_images.xsl new file mode 100644 index 00000000..8254a674 --- /dev/null +++ b/kopete/plugins/webpresence/webpresence_xhtml_images.xsl @@ -0,0 +1,60 @@ + + + + + + + + + + + + images + + + + + MSN + + + ICQ + + + Jabber + + + Yahoo + + + AIM + + + IRC + + + SMS + + + Gadu-Gadu + + + WinPopup + + + + + + + diff --git a/kopete/plugins/webpresence/webpresenceplugin.cpp b/kopete/plugins/webpresence/webpresenceplugin.cpp new file mode 100644 index 00000000..1856d94c --- /dev/null +++ b/kopete/plugins/webpresence/webpresenceplugin.cpp @@ -0,0 +1,473 @@ +/* + webpresenceplugin.cpp + + Kopete Web Presence plugin + + Copyright (c) 2005 by Tommi Rantala + Copyright (c) 2002,2003 by Will Stephenson + + Kopete (c) 2002-2005 by the Kopete developers + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* + */ + +#include "config.h" + +#include +#include +#include + +#include +#include +#include +#include +#include +#include + +#ifdef HAVE_XSLT +#include +#include + +#include +#include +#include +#include +#endif + +#include "kopetepluginmanager.h" +#include "kopeteprotocol.h" +#include "kopeteaccountmanager.h" +#include "kopeteaccount.h" + +#include "webpresenceplugin.h" + +typedef KGenericFactory WebPresencePluginFactory; +K_EXPORT_COMPONENT_FACTORY( kopete_webpresence, WebPresencePluginFactory( "kopete_webpresence" ) ) + +WebPresencePlugin::WebPresencePlugin( QObject *parent, const char *name, const QStringList& /*args*/ ) + : Kopete::Plugin( WebPresencePluginFactory::instance(), parent, name ), + shuttingDown( false ), resultFormatting( WEB_HTML ) +{ + m_writeScheduler = new QTimer( this ); + connect ( m_writeScheduler, SIGNAL( timeout() ), this, SLOT( slotWriteFile() ) ); + connect( Kopete::AccountManager::self(), SIGNAL(accountRegistered(Kopete::Account*)), + this, SLOT( listenToAllAccounts() ) ); + connect( Kopete::AccountManager::self(), SIGNAL(accountUnregistered(Kopete::Account*)), + this, SLOT( listenToAllAccounts() ) ); + + connect(this, SIGNAL(settingsChanged()), this, SLOT( loadSettings() ) ); + loadSettings(); + listenToAllAccounts(); +} + +WebPresencePlugin::~WebPresencePlugin() +{ +} + +void WebPresencePlugin::loadSettings() +{ + KConfig *kconfig = KGlobal::config(); + kconfig->setGroup( "Web Presence Plugin" ); + + frequency = kconfig->readNumEntry("UploadFrequency", 15); + resultURL = kconfig->readPathEntry("uploadURL"); + + resultFormatting = WEB_UNDEFINED; + + if ( kconfig->readBoolEntry( "formatHTML", false ) ) { + resultFormatting = WEB_HTML; + } else if ( kconfig->readBoolEntry( "formatXHTML", false ) ) { + resultFormatting = WEB_XHTML; + } else if ( kconfig->readBoolEntry( "formatXML", false ) ) { + resultFormatting = WEB_XML; + } else if ( kconfig->readBoolEntry( "formatStylesheet", false ) ) { + resultFormatting = WEB_CUSTOM; + userStyleSheet = kconfig->readEntry("formatStylesheetURL"); + } + + // Default to HTML if we dont get anything useful from config file. + if ( resultFormatting == WEB_UNDEFINED ) + resultFormatting = WEB_HTML; + + useImagesInHTML = kconfig->readBoolEntry( "useImagesHTML", false ); + useImName = kconfig->readBoolEntry("showName", true); + userName = kconfig->readEntry("showThisName"); + showAddresses = kconfig->readBoolEntry("includeIMAddress", false); + + // Update file when settings are changed. + slotWriteFile(); +} + +void WebPresencePlugin::listenToAllAccounts() +{ + // connect to signals notifying of all accounts' status changes + ProtocolList protocols = allProtocols(); + + for ( ProtocolList::Iterator it = protocols.begin(); + it != protocols.end(); ++it ) + { + QDict accounts = Kopete::AccountManager::self()->accounts( *it ); + QDictIterator acIt( accounts ); + + for( ; Kopete::Account *account = acIt.current(); ++acIt ) + { + listenToAccount( account ); + } + } + slotWaitMoreStatusChanges(); +} + +void WebPresencePlugin::listenToAccount( Kopete::Account* account ) +{ + if(account && account->myself()) + { + // Connect to the account's status changed signal + // because we can't know if the account has already connected + QObject::disconnect( account->myself(), + SIGNAL(onlineStatusChanged( Kopete::Contact *, + const Kopete::OnlineStatus &, + const Kopete::OnlineStatus & ) ), + this, + SLOT( slotWaitMoreStatusChanges() ) ) ; + QObject::connect( account->myself(), + SIGNAL(onlineStatusChanged( Kopete::Contact *, + const Kopete::OnlineStatus &, + const Kopete::OnlineStatus & ) ), + this, + SLOT( slotWaitMoreStatusChanges() ) ); + } +} + +void WebPresencePlugin::slotWaitMoreStatusChanges() +{ + if ( !m_writeScheduler->isActive() ) + m_writeScheduler->start( frequency * 1000 ); +} + +void WebPresencePlugin::slotWriteFile() +{ + m_writeScheduler->stop(); + + // generate the (temporary) XML file representing the current contactlist + KURL dest( resultURL ); + if ( resultURL.isEmpty() || !dest.isValid() ) + { + kdDebug(14309) << "url is empty or not valid. NOT UPDATING!" << endl; + return; + } + + KTempFile* xml = generateFile(); + xml->setAutoDelete( true ); + kdDebug(14309) << k_funcinfo << " " << xml->name() << endl; + + switch( resultFormatting ) { + case WEB_XML: + m_output = xml; + xml = 0L; + break; + case WEB_HTML: + case WEB_XHTML: + case WEB_CUSTOM: + m_output = new KTempFile(); + m_output->setAutoDelete( true ); + + if ( !transform( xml, m_output ) ) + { + //TODO: give some error to user, even better if shown only once + delete m_output; + m_output = 0L; + + delete xml; + return; + } + + delete xml; // might make debugging harder! + break; + default: + return; + } + + // upload it to the specified URL + KURL src( m_output->name() ); + KIO::FileCopyJob *job = KIO::file_move( src, dest, -1, true, false, false ); + connect( job, SIGNAL( result( KIO::Job * ) ), + SLOT( slotUploadJobResult( KIO::Job * ) ) ); +} + +void WebPresencePlugin::slotUploadJobResult( KIO::Job *job ) +{ + if ( job->error() ) { + kdDebug(14309) << "Error uploading presence info." << endl; + KMessageBox::queuedDetailedError( 0, i18n("An error occurred when uploading your presence page.\nCheck the path and write permissions of the destination."), 0, displayName() ); + delete m_output; + m_output = 0L; + } +} + +KTempFile* WebPresencePlugin::generateFile() +{ + // generate the (temporary) XML file representing the current contactlist + kdDebug( 14309 ) << k_funcinfo << endl; + QString notKnown = i18n( "Not yet known" ); + + QDomDocument doc; + + doc.appendChild( doc.createProcessingInstruction( "xml", + "version=\"1.0\" encoding=\"UTF-8\"" ) ); + + QDomElement root = doc.createElement( "webpresence" ); + doc.appendChild( root ); + + // insert the current date/time + QDomElement date = doc.createElement( "listdate" ); + QDomText t = doc.createTextNode( + KGlobal::locale()->formatDateTime( QDateTime::currentDateTime() ) ); + date.appendChild( t ); + root.appendChild( date ); + + // insert the user's name + QDomElement name = doc.createElement( "name" ); + QDomText nameText; + if ( !useImName && !userName.isEmpty() ) + nameText = doc.createTextNode( userName ); + else + nameText = doc.createTextNode( notKnown ); + name.appendChild( nameText ); + root.appendChild( name ); + + // insert the list of the user's accounts + QDomElement accounts = doc.createElement( "accounts" ); + root.appendChild( accounts ); + + QPtrList list = Kopete::AccountManager::self()->accounts(); + // If no accounts, stop here + if ( !list.isEmpty() ) + { + for( QPtrListIterator it( list ); + Kopete::Account *account=it.current(); + ++it ) + { + QDomElement acc = doc.createElement( "account" ); + //output += h.openTag( "account" ); + + QDomElement protoName = doc.createElement( "protocol" ); + QDomText protoNameText = doc.createTextNode( + account->protocol()->pluginId() ); + protoName.appendChild( protoNameText ); + acc.appendChild( protoName ); + + Kopete::Contact* me = account->myself(); + QString displayName = me->property( Kopete::Global::Properties::self()->nickName() ).value().toString(); + QDomElement accName = doc.createElement( "accountname" ); + QDomText accNameText = doc.createTextNode( ( me ) + ? displayName + : notKnown ); + accName.appendChild( accNameText ); + acc.appendChild( accName ); + + QDomElement accStatus = doc.createElement( "accountstatus" ); + QDomText statusText = doc.createTextNode( ( me ) + ? statusAsString( me->onlineStatus() ) + : notKnown ) ; + accStatus.appendChild( statusText ); + + // Dont add these if we're shutting down, because the result + // would be quite weird. + if ( !shuttingDown ) { + + // Add away message as an attribute, if one exists. + if ( me->onlineStatus().status() == Kopete::OnlineStatus::Away && + !me->property("awayMessage").value().toString().isEmpty() ) { + accStatus.setAttribute( "awayreason", + me->property("awayMessage").value().toString() ); + } + + // Add the online status description as an attribute, if one exits. + if ( !me->onlineStatus().description().isEmpty() ) { + accStatus.setAttribute( "statusdescription", + me->onlineStatus().description() ); + } + } + acc.appendChild( accStatus ); + + if ( showAddresses ) + { + QDomElement accAddress = doc.createElement( "accountaddress" ); + QDomText addressText = doc.createTextNode( ( me ) + ? me->contactId() + : notKnown ); + accAddress.appendChild( addressText ); + acc.appendChild( accAddress ); + } + + accounts.appendChild( acc ); + } + } + + // write the XML to a temporary file + KTempFile* file = new KTempFile(); + QTextStream *stream = file->textStream(); + stream->setEncoding( QTextStream::UnicodeUTF8 ); + doc.save( *stream, 4 ); + file->close(); + return file; +} + +bool WebPresencePlugin::transform( KTempFile * src, KTempFile * dest ) +{ +#ifdef HAVE_XSLT + bool retval = true; + xmlSubstituteEntitiesDefault( 1 ); + xmlLoadExtDtdDefaultValue = 1; + + QFile sheet; + + switch ( resultFormatting ) { + case WEB_XML: + // Oops! We tried to call transform() but XML was requested. + return false; + case WEB_HTML: + if ( useImagesInHTML ) { + sheet.setName( locate( "appdata", "webpresence/webpresence_html_images.xsl" ) ); + } else { + sheet.setName( locate( "appdata", "webpresence/webpresence_html.xsl" ) ); + } + break; + case WEB_XHTML: + if ( useImagesInHTML ) { + sheet.setName( locate( "appdata", "webpresence/webpresence_xhtml_images.xsl" ) ); + } else { + sheet.setName( locate( "appdata", "webpresence/webpresence_xhtml.xsl" ) ); + } + break; + case WEB_CUSTOM: + sheet.setName( userStyleSheet ); + break; + default: + // Shouldn't ever reach here. + return false; + } + + // TODO: auto / smart pointers would be useful here + xsltStylesheetPtr cur = 0; + xmlDocPtr doc = 0; + xmlDocPtr res = 0; + + if ( !sheet.exists() ) { + kdDebug(14309) << k_funcinfo << "ERROR: Style sheet not found" << endl; + retval = false; + goto end; + } + + // is the cast safe? + cur = xsltParseStylesheetFile( (const xmlChar *) sheet.name().latin1() ); + if ( !cur ) { + kdDebug(14309) << k_funcinfo << "ERROR: Style sheet parsing failed" << endl; + retval = false; + goto end; + } + + doc = xmlParseFile( QFile::encodeName( src->name() ) ); + if ( !doc ) { + kdDebug(14309) << k_funcinfo << "ERROR: XML parsing failed" << endl; + retval = false; + goto end; + } + + res = xsltApplyStylesheet( cur, doc, 0 ); + if ( !res ) { + kdDebug(14309) << k_funcinfo << "ERROR: Style sheet apply failed" << endl; + retval = false; + goto end; + } + + if ( xsltSaveResultToFile(dest->fstream(), res, cur) == -1 ) { + kdDebug(14309) << k_funcinfo << "ERROR: Style sheet apply failed" << endl; + retval = false; + goto end; + } + + // then it all worked! + dest->close(); + +end: + xsltCleanupGlobals(); + xmlCleanupParser(); + if (doc) xmlFreeDoc(doc); + if (res) xmlFreeDoc(res); + if (cur) xsltFreeStylesheet(cur); + + return retval; + +#else + Q_UNUSED( src ); + Q_UNUSED( dest ); + + return false; +#endif +} + +ProtocolList WebPresencePlugin::allProtocols() +{ + kdDebug( 14309 ) << k_funcinfo << endl; + + Kopete::PluginList plugins = Kopete::PluginManager::self()->loadedPlugins( "Protocols" ); + Kopete::PluginList::ConstIterator it; + + ProtocolList result; + + for ( it = plugins.begin(); it != plugins.end(); ++it ) { + result.append( static_cast( *it ) ); + } + + return result; +} + +QString WebPresencePlugin::statusAsString( const Kopete::OnlineStatus &newStatus ) +{ + if (shuttingDown) + return "OFFLINE"; + + QString status; + switch ( newStatus.status() ) + { + case Kopete::OnlineStatus::Online: + status = "ONLINE"; + break; + case Kopete::OnlineStatus::Away: + status = "AWAY"; + break; + case Kopete::OnlineStatus::Offline: + case Kopete::OnlineStatus::Invisible: + status = "OFFLINE"; + break; + default: + status = "UNKNOWN"; + } + + return status; +} + +void WebPresencePlugin::aboutToUnload() +{ + // Stop timer. Dont need it anymore. + m_writeScheduler->stop(); + + // Force statusAsString() report all accounts as OFFLINE. + shuttingDown = true; + + // Do final update of webpresence file. + slotWriteFile(); + + emit readyForUnload(); +} + +// vim: set noet ts=4 sts=4 sw=4: +#include "webpresenceplugin.moc" diff --git a/kopete/plugins/webpresence/webpresenceplugin.h b/kopete/plugins/webpresence/webpresenceplugin.h new file mode 100644 index 00000000..3aea9af0 --- /dev/null +++ b/kopete/plugins/webpresence/webpresenceplugin.h @@ -0,0 +1,123 @@ +/* + webpresenceplugin.h + + Kopete Web Presence plugin + + Copyright (c) 2002,2003 by Will Stephenson + + Kopete (c) 2002,2003 by the Kopete developers + + ************************************************************************* + * * + * 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. * + * * + ************************************************************************* +*/ + +#ifndef WEBPRESENCEPLUGIN_H +#define WEBPRESENCEPLUGIN_H + +#include + +#include + +#include "kopetecontact.h" +#include "kopeteonlinestatus.h" + +class QTimer; +class KTempFile; +namespace Kopete { class MetaContact; } +class KToggleAction; +class KActionCollection; + +typedef QValueList ProtocolList; + +class WebPresencePlugin : public Kopete::Plugin +{ + Q_OBJECT + +private: + int frequency; + bool showAddresses; + bool useImName; + QString userName; + QString userStyleSheet; + bool useImagesInHTML; + + // Is set to true when Kopete has notified us + // that we're about to be unloaded. + bool shuttingDown; + + enum { + WEB_HTML, + WEB_XHTML, + WEB_XML, + WEB_CUSTOM, + WEB_UNDEFINED + } resultFormatting; + + QString resultURL; + +public: + WebPresencePlugin( QObject *parent, const char *name, const QStringList &args ); + virtual ~WebPresencePlugin(); + + virtual void aboutToUnload(); + +protected slots: + void loadSettings(); + + /** + * Write a file to the specified location, + */ + void slotWriteFile(); + /** + * Called when an upload finished, displays error if needed + */ + void slotUploadJobResult( KIO::Job * ); + /** + * Called to schedule a write, after waiting to see if more changes + * occur (accounts tend to change status together) + */ + void slotWaitMoreStatusChanges(); + /** + * Sets us up to respond to account status changes + */ + void listenToAllAccounts(); + /** + * Sets us up to respond to a new account + */ + void listenToAccount( Kopete::Account* account ); + +protected: + /** + * Generate the file (HTML, text) to be uploaded + */ + KTempFile* generateFile(); + /** + * Apply named stylesheet to get content and presentation + */ + bool transform( KTempFile* src, KTempFile* dest ); + /** + * Helper method, generates list of all IM protocols + */ + ProtocolList allProtocols(); + /** + * Converts numeric status to a string + */ + QString statusAsString( const Kopete::OnlineStatus &newStatus ); + /** + * Schedules writes + */ + QTimer* m_writeScheduler; + + // The file to be uploaded to the WWW + KTempFile *m_output; +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/webpresence/webpresencepreferences.cpp b/kopete/plugins/webpresence/webpresencepreferences.cpp new file mode 100644 index 00000000..9b00435a --- /dev/null +++ b/kopete/plugins/webpresence/webpresencepreferences.cpp @@ -0,0 +1,64 @@ +/*************************************************************************** + webpresencepreferences.cpp + ------------------- + begin : jeu nov 14 2002 + copyright : (C) 2002 by Olivier Goffart + email : ogoffart @ kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#include + +#include +#include +#include + +#include "webpresenceprefs.h" +#include "webpresencepreferences.h" + +typedef KGenericFactory WebPresencePreferencesFactory; +K_EXPORT_COMPONENT_FACTORY( kcm_kopete_webpresence, WebPresencePreferencesFactory("kcm_kopete_webpresence")) + +WebPresencePreferences::WebPresencePreferences(QWidget *parent, const char* /*name*/, const QStringList &args) + : KCModule(WebPresencePreferencesFactory::instance(), parent, args) +{ + // Add actuall widget generated from ui file. + ( new QVBoxLayout( this ) )->setAutoAdd( true ); + preferencesDialog = new WebPresencePrefsUI(this); + preferencesDialog->uploadURL->setMode( KFile::File ); + preferencesDialog->formatStylesheetURL->setFilter( "*.xsl" ); + + // KAutoConfig stuff + kautoconfig = new KAutoConfig(KGlobal::config(), this, "kautoconfig"); + connect(kautoconfig, SIGNAL(widgetModified()), SLOT(widgetModified())); + connect(kautoconfig, SIGNAL(settingsChanged()), SLOT(widgetModified())); + kautoconfig->addWidget(preferencesDialog, "Web Presence Plugin"); + kautoconfig->retrieveSettings(true); +} + +void WebPresencePreferences::widgetModified() +{ + emit KCModule::changed(kautoconfig->hasChanged()); +} + +void WebPresencePreferences::save() +{ + kautoconfig->saveSettings(); +} + +void WebPresencePreferences::defaults () +{ + kautoconfig->resetSettings(); +} + +#include "webpresencepreferences.moc" + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/webpresence/webpresencepreferences.h b/kopete/plugins/webpresence/webpresencepreferences.h new file mode 100644 index 00000000..120e7a9a --- /dev/null +++ b/kopete/plugins/webpresence/webpresencepreferences.h @@ -0,0 +1,50 @@ +/*************************************************************************** + webpresencepreferences.h + ------------------- + begin : jeu nov 14 2002 + copyright : (C) 2002 by Olivier Goffart + email : ogoffart @ kde.org + ***************************************************************************/ + +/*************************************************************************** + * * + * 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. * + * * + ***************************************************************************/ + +#ifndef WEBPRSENCEPREFERECES_H +#define WEBPRSENCEPREFERECES_H + +#include "kcmodule.h" + +class WebPresencePrefsUI; +class KAutoConfig; + +/** + * Preference widget for the Now Listening plugin, copied from the Cryptography plugin + * @author Olivier Goffart + */ +class WebPresencePreferences : public KCModule { + Q_OBJECT + +public: + WebPresencePreferences(QWidget *parent = 0, const char *name = 0, const QStringList &args = QStringList()); + + virtual void save(); + virtual void defaults(); + +private: + WebPresencePrefsUI *preferencesDialog; + KAutoConfig *kautoconfig; + +private slots: // Public slots + void widgetModified(); + +}; + +#endif + +// vim: set noet ts=4 sts=4 sw=4: diff --git a/kopete/plugins/webpresence/webpresenceprefs.ui b/kopete/plugins/webpresence/webpresenceprefs.ui new file mode 100644 index 00000000..9aae819a --- /dev/null +++ b/kopete/plugins/webpresence/webpresenceprefs.ui @@ -0,0 +1,369 @@ + +WebPresencePrefsUI + + + WebPresencePrefsUI + + + true + + + + 0 + 0 + 426 + 554 + + + + + unnamed + + + 11 + + + 6 + + + + groupBox1 + + + Uploading + + + + unnamed + + + 11 + + + 6 + + + + textLabel1 + + + NoFrame + + + Plain + + + Uplo&ad to: + + + uploadURL + + + + + uploadURL + + + + + spacer5 + + + Horizontal + + + Expanding + + + + 449 + 0 + + + + + + + + buttonGroup2_2 + + + Formatting + + + + unnamed + + + 11 + + + 6 + + + + formatHTML + + + HTML (simple loo&k) + + + true + + + HTML 4.01 Transitional using the ISO-8859-1 (aka. Latin 1) character set encoding. + + + HTML 4.01 Transitional formatting using ISO-8859-1 (aka. Latin 1) character set encoding. + +This version should be easily opened by most web browsers. + + + + + formatXHTML + + + XHTML (simple look) + + + XHTML 1.0 Strict + + + The resulting page will be formatted using the XHTML 1.0 Strict W3C Recommendation. The character set encoding is UTF-8. + +Note that some web browsers do not support XHTML. You should also make sure your web server serves it out with the correct mime type, such as application/xhtml+xml. + + + + + formatXML + + + &XML + + + Save the output in XML format using UTF-8 character set. + + + Save the output in XML format using the UTF-8 encoding. + + + + + formatStylesheet + + + XML transformation &using this XSLT sheet: + + + + + layout1 + + + + unnamed + + + + spacer10 + + + Horizontal + + + Fixed + + + + 30 + 20 + + + + + + formatStylesheetURL + + + false + + + + + + + useImagesHTML + + + Repla&ce protocol text with images in (X)HTML + + + Replaces the protocol names, such as MSN and IRC with images. + + + Replaces the protocol names, such as MSN and IRC with images. + +Note that you have to manually copy the PNG files into place. + +The following files are used by default: + +images/msn_protocol.png +images/icq_protocol.png +images/jabber_protocol.png +images/yahoo_protocol.png +images/aim_protocol.png +images/irc_protocol.png +images/sms_protocol.png +images/gadu_protocol.png +images/winpopup_protocol.png + + + + + + + buttonGroup2 + + + Display Name + + + + unnamed + + + 11 + + + 6 + + + + showName + + + Use one of &your IM names + + + true + + + + + showAnotherName + + + Use another &name: + + + + + layout2 + + + + unnamed + + + + spacer4_2 + + + Horizontal + + + Fixed + + + + 30 + 20 + + + + + + showThisName + + + false + + + + + + + includeIMAddress + + + Include &IM addresses + + + + + + + Spacer7 + + + Vertical + + + Expanding + + + + 16 + 93 + + + + + + + + formatStylesheet + toggled(bool) + formatStylesheetURL + setEnabled(bool) + + + showAnotherName + toggled(bool) + showThisName + setEnabled(bool) + + + formatXML + toggled(bool) + useImagesHTML + setDisabled(bool) + + + formatStylesheet + toggled(bool) + useImagesHTML + setDisabled(bool) + + + + uploadURL + formatHTML + formatStylesheetURL + useImagesHTML + showName + showThisName + includeIMAddress + + + + kurlrequester.h + klineedit.h + kpushbutton.h + kurlrequester.h + klineedit.h + kpushbutton.h + + -- cgit v1.2.1