mirror of
https://bitbucket.org/smil3y/kde-workspace.git
synced 2025-02-23 10:22:49 +00:00
generic: ajdust to kdnssd library changes
This commit is contained in:
parent
875f2be0bc
commit
494297b408
68 changed files with 96 additions and 5440 deletions
|
@ -32,7 +32,6 @@ add_subdirectory( knotify )
|
|||
add_subdirectory( componentchooser )
|
||||
add_subdirectory( mediaplayer )
|
||||
add_subdirectory( menus )
|
||||
add_subdirectory( dnssd )
|
||||
add_subdirectory( spellchecking )
|
||||
|
||||
add_subdirectory( kdebug )
|
||||
|
|
|
@ -1,20 +0,0 @@
|
|||
########### next target ###############
|
||||
|
||||
kde4_add_plugin(kcm_kdnssd kcmdnssd.cpp)
|
||||
|
||||
target_link_libraries(kcm_kdnssd
|
||||
${KDE4_KDNSSD_LIBS}
|
||||
${KDE4_KDEUI_LIBS}
|
||||
)
|
||||
|
||||
install(
|
||||
TARGETS kcm_kdnssd
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
########### install files ###############
|
||||
|
||||
install(
|
||||
FILES kcm_kdnssd.desktop
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
|
@ -1,3 +0,0 @@
|
|||
#!/bin/bash
|
||||
$EXTRACTRC *.ui >> rc.cpp
|
||||
$XGETTEXT *.cpp *.h -o $podir/kcmkdnssd.pot
|
|
@ -1,63 +0,0 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>ConfigDialog</class>
|
||||
<widget class="QWidget" name="ConfigDialog">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>571</width>
|
||||
<height>486</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout_2">
|
||||
<item row="0" column="0">
|
||||
<widget class="QGroupBox" name="groupBox">
|
||||
<property name="title">
|
||||
<string>Additional Domains</string>
|
||||
</property>
|
||||
<layout class="QGridLayout" name="gridLayout">
|
||||
<item row="0" column="0">
|
||||
<widget class="KEditListWidget" name="kcfg_DomainList">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="whatsThis">
|
||||
<string>List of Internet domains that will be browsed for services in addition to default domain (typically local network). </string>
|
||||
</property>
|
||||
<property name="title" stdset="0">
|
||||
<string>Additional Domains</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>KEditListWidget</class>
|
||||
<extends>QWidget</extends>
|
||||
<header>keditlistwidget.h</header>
|
||||
<container>1</container>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
|
@ -1,193 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Exec=kcmshell4 kcm_kdnssd
|
||||
Icon=preferences-system-network-discovery
|
||||
Name=Service Discovery
|
||||
Name[af]=Dienste ontdekker
|
||||
Name[ar]=استكشاف الخدمة
|
||||
Name[ast]=Guetador de servicios
|
||||
Name[be]=Пошук сервісаў
|
||||
Name[be@latin]=Pošuk słužbaŭ
|
||||
Name[bg]=Откриване на услуги
|
||||
Name[bn]=সার্ভিস উদ্ঘাটন
|
||||
Name[bn_IN]=পরিসেবার ডিরেক্টরি
|
||||
Name[bs]=Otkrivanje servisa
|
||||
Name[ca]=Descobriment de serveis
|
||||
Name[ca@valencia]=Descobriment de serveis
|
||||
Name[cs]=Hledání služeb
|
||||
Name[csb]=Wëkrëwanié ùsłëżnotów
|
||||
Name[da]=Opdagelse af tjenester
|
||||
Name[de]=Diensteerkennung
|
||||
Name[el]=Εύρεση υπηρεσιών
|
||||
Name[en_GB]=Service Discovery
|
||||
Name[eo]=Malkovrado de servo
|
||||
Name[es]=Buscador de servicios
|
||||
Name[et]=Teenuste tuvastamine
|
||||
Name[eu]=Zerbitzu-aurkikuntza
|
||||
Name[fa]=کشف خدمت
|
||||
Name[fi]=Palvelun havaitseminen
|
||||
Name[fr]=Découverte de services
|
||||
Name[fy]=Tsjinst warskôging
|
||||
Name[ga]=Fionnachtain Seirbhísí
|
||||
Name[gl]=Descubrimento de servizos
|
||||
Name[gu]=સેવા શોધ
|
||||
Name[he]=גילוי שירותים
|
||||
Name[hi]=सेवा डिस्कवरी
|
||||
Name[hne]=सेवा डिस्कवरी
|
||||
Name[hr]=Usluga Discovery
|
||||
Name[hsb]=Pytanje słužbow
|
||||
Name[hu]=Zeroconf-beállítások
|
||||
Name[ia]=Discoperta de Servicio
|
||||
Name[id]=Penemuan Layanan
|
||||
Name[is]=Uppgötvun þjónustu
|
||||
Name[it]=Rilevamento dei servizi
|
||||
Name[ja]=サービスディスカバリ
|
||||
Name[ka]=სერვისის აღმოჩენა
|
||||
Name[kk]=Қызметтерді байқау
|
||||
Name[km]=ការរកឃើញសេវា
|
||||
Name[kn]=ಸೇವಾ ಆವಿಷ್ಕಾರ (ಸರ್ವೀಸ್ ಡಿಸ್ಕವರಿ)
|
||||
Name[ko]=서비스 발견
|
||||
Name[ku]=Naskirina Servîsê
|
||||
Name[lt]=Tarnybų radimas
|
||||
Name[lv]=Servisu atklāšana
|
||||
Name[mai]=सेवा डिस्कवरी
|
||||
Name[mk]=Откривање сервиси
|
||||
Name[ml]=സേവനം കണ്ടെത്തല്
|
||||
Name[mr]=सेवा आढळली
|
||||
Name[ms]=Penemuan Servis
|
||||
Name[nb]=Oppdaging av tjenester
|
||||
Name[nds]=Deensten finnen
|
||||
Name[ne]=सेवा खोजी
|
||||
Name[nl]=Dienstwaarneming
|
||||
Name[nn]=Oppdaging av tenester
|
||||
Name[or]=ସର୍ଭିସ ଆବିଷ୍କାର
|
||||
Name[pa]=ਸਰਵਿਸ ਖੋਜ
|
||||
Name[pl]=Wykrywanie usług
|
||||
Name[pt]=Descoberta de Serviços
|
||||
Name[pt_BR]=Descoberta de serviços
|
||||
Name[ro]=Descoperire servicii
|
||||
Name[ru]=Обнаружение служб
|
||||
Name[se]=Bálvalusáican
|
||||
Name[si]=සේවා අනාවරණය
|
||||
Name[sk]=Zisťovanie služieb
|
||||
Name[sl]=Odkrivanje storitev
|
||||
Name[sr]=Откривање сервиса
|
||||
Name[sr@ijekavian]=Откривање сервиса
|
||||
Name[sr@ijekavianlatin]=Otkrivanje servisa
|
||||
Name[sr@latin]=Otkrivanje servisa
|
||||
Name[sv]=Tjänstupptäckt
|
||||
Name[ta]=சர்வீஸ் டிஸ்கவரி
|
||||
Name[te]=
|
||||
Name[tg]=Дарёфтани хизматҳо
|
||||
Name[th]=การค้นหาบริการ
|
||||
Name[tr]=Servis Araştırması
|
||||
Name[ug]=مۇلازىمەت بايقاش
|
||||
Name[uk]=Пошук служб
|
||||
Name[uz]=Tarmoqdagi xizmatlarni qidirish
|
||||
Name[uz@cyrillic]=Тармоқдаги хизматларни қидириш
|
||||
Name[vi]=Khám phá dịch vụ
|
||||
Name[wa]=Discovraedje di siervices
|
||||
Name[x-test]=xxService Discoveryxx
|
||||
Name[zh_CN]=服务探索
|
||||
Name[zh_TW]=服務偵測
|
||||
|
||||
Comment=Configure service discovery
|
||||
Comment[af]=Stel dienste ontdekker op
|
||||
Comment[ar]=اضبط استكشاف الخدمة
|
||||
Comment[ast]=Configura'l guetador de servicios
|
||||
Comment[be]=Настаўленні пошуку сервісаў
|
||||
Comment[be@latin]=Naładź pošuk słužbaŭ
|
||||
Comment[bg]=Настройване откриването на услуги
|
||||
Comment[bn]=সার্ভিস উদ্ঘাটন কনফিগার করুন
|
||||
Comment[bn_IN]=পরিসেবার ডিরেক্টরি কনফিগার করুন
|
||||
Comment[bs]=Podešavanje otkrivanja servisa
|
||||
Comment[ca]=Configura el descobriment de serveis
|
||||
Comment[ca@valencia]=Configura el descobriment de serveis
|
||||
Comment[cs]=Nastavení hledání služeb
|
||||
Comment[csb]=Kòfigùracëjô wëkrëwaniô ùsłëżnotów
|
||||
Comment[da]=Indstil opdagelse af tjeneste
|
||||
Comment[de]=Diensteerkennung einrichten
|
||||
Comment[el]=Διαμόρφωση εύρεσης υπηρεσιών
|
||||
Comment[en_GB]=Configure service discovery
|
||||
Comment[eo]=Agordi malkovradon de servo
|
||||
Comment[es]=Configura el buscador de servicios
|
||||
Comment[et]=Teenuste tuvastamise seadistamine
|
||||
Comment[eu]=Zerbitzu-aurkikuntzaren konfigurazioa
|
||||
Comment[fa]=پیکربندی کشف خدمت
|
||||
Comment[fi]=Palvelun havaitsemisen asetukset
|
||||
Comment[fr]=Configuration de la découverte de services
|
||||
Comment[fy]=Tsjinst waarnimming ynstellen
|
||||
Comment[ga]=Cumraigh fionnachtain seirbhísí
|
||||
Comment[gl]=Configurar o descubrimento de servizos
|
||||
Comment[gu]=સેવા શોધ રૂપરેખાંકિત કરો
|
||||
Comment[he]=שינוי הגדרות הקשורות לגילוי שירותים
|
||||
Comment[hi]=सेवा डिस्कवरी कॉन्फ़िगर करें
|
||||
Comment[hne]=सेवा डिस्कवरी कान्फिगर करव
|
||||
Comment[hr]=Konfiguriranje usluge discovery
|
||||
Comment[hsb]=Pytanje słužbow připrawić
|
||||
Comment[hu]=A szolgáltatásdetektálás beállításai
|
||||
Comment[ia]=Configura discoperta de servicio
|
||||
Comment[id]=Atur penemuan layanan
|
||||
Comment[is]=Stilla uppgötvun þjónustna
|
||||
Comment[it]=Configura il rilevamento dei servizi
|
||||
Comment[ja]=サービスディスカバリの設定
|
||||
Comment[ka]=სერვისის არმოჩენის კონფიგურირება
|
||||
Comment[kk]=Қызыметтерді байқауды баптау
|
||||
Comment[km]=កំណត់រចនាសម្ព័ន្ធការរកឃើញសេវា
|
||||
Comment[kn]=ಸೇವಾ ಆವಿಷ್ಕಾರವನ್ನು (ಸರ್ವೀಸ್ ಡಿಸ್ಕವರಿ) ಸಂರಚಿಸು
|
||||
Comment[ko]=서비스 발견 설정
|
||||
Comment[ku]=naskirina servîsê mîheng bike
|
||||
Comment[lt]=Konfigūruoti tarnybų radimą
|
||||
Comment[lv]=Konfigurē servisu atklāšanu
|
||||
Comment[mai]=सेवा डिस्कवरी बिन्यस्त करू
|
||||
Comment[mk]=Конфигурирајте го откривањето сервиси
|
||||
Comment[ml]=സേവനം കണ്ടെത്തല് ക്രമീകരണം
|
||||
Comment[mr]=सेवा आढळल्यास संयोजीत करा
|
||||
Comment[ms]=Konfigur penemuan servis
|
||||
Comment[nb]=Tilpass tjenesteoppdagingen
|
||||
Comment[nds]=Dat Finnen vun Deensten inrichten
|
||||
Comment[ne]=सेवा खोजी कन्फिगर गर्नुहोस्
|
||||
Comment[nl]=Dienstwaarneming instellen
|
||||
Comment[nn]=Set opp oppdagingstenesta
|
||||
Comment[or]=ସର୍ଭିସ ଆବିଷ୍କାର ବିନ୍ୟାସ କରନ୍ତୁ
|
||||
Comment[pa]=ਸਰਵਿਸ ਖੋਜ ਸੰਰਚਨਾ
|
||||
Comment[pl]=Ustawienia wykrywania usług
|
||||
Comment[pt]=Configurar a descoberta de serviços
|
||||
Comment[pt_BR]=Configura a descoberta de serviços
|
||||
Comment[ro]=Configurează serviciul de descoperire
|
||||
Comment[ru]=Настройка обнаружения служб
|
||||
Comment[se]=Heivet bálvalusáicama
|
||||
Comment[si]=සේවා අනාවරණය සැකසීම
|
||||
Comment[sk]=Nastavenie zisťovania služieb
|
||||
Comment[sl]=Nastavi odkrivanje storitev
|
||||
Comment[sr]=Подешавање откривања сервиса
|
||||
Comment[sr@ijekavian]=Подешавање откривања сервиса
|
||||
Comment[sr@ijekavianlatin]=Podešavanje otkrivanja servisa
|
||||
Comment[sr@latin]=Podešavanje otkrivanja servisa
|
||||
Comment[sv]=Anpassa tjänstupptäckt
|
||||
Comment[ta]=சர்வீஸ் டிஸ்கவரியை வடிவமை
|
||||
Comment[te]=సేవా డిస్కవరిని ఆకృతీకరించుము
|
||||
Comment[tg]=Танзимоти дарёфтани хизматҳо
|
||||
Comment[th]=ปรับแต่งการค้นหาบริการ
|
||||
Comment[tr]=Servis araştırmasını yapılandır
|
||||
Comment[ug]=مۇلازىمەت بايقاش سەپلىمىسى
|
||||
Comment[uk]=Налаштування знаходження служб
|
||||
Comment[uz]=Tarmoqdagi xizmatlarni qidirishni moslash
|
||||
Comment[uz@cyrillic]=Тармоқдаги хизматларни қидиришни мослаш
|
||||
Comment[vi]=Cấu hình khả năng khám phám dịch vụ
|
||||
Comment[wa]=Apontyî l' discovraedje di siervices
|
||||
Comment[x-test]=xxConfigure service discoveryxx
|
||||
Comment[zh_CN]=配置服务探索
|
||||
Comment[zh_TW]=設定服務偵測
|
||||
StartupNotify=true
|
||||
Terminal=false
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KCModule
|
||||
X-DBUS-StartupType=
|
||||
X-KDE-HasReadOnlyMode=false
|
||||
X-KDE-Library=kcm_kdnssd
|
||||
X-KDE-ParentApp=kcontrol
|
||||
X-KDE-SubstituteUID=false
|
||||
X-KDE-RootOnly=true
|
||||
Categories=Qt;KDE;X-KDE-settings-network;
|
||||
X-KDE-System-Settings-Parent-Category=network-settings
|
||||
X-KDE-Weight=70
|
|
@ -1,74 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2004,2005 by Jakub Stachowski *
|
||||
* qbast@go2.pl *
|
||||
* *
|
||||
* 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 "kcmdnssd.h"
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <config-workspace.h>
|
||||
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
//Added by qt3to4:
|
||||
|
||||
#include <klocale.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kpluginfactory.h>
|
||||
#include <kpluginloader.h>
|
||||
|
||||
#include <dnssd/settings.h>
|
||||
#include <dnssd/domainbrowser.h>
|
||||
|
||||
#define MDNSD_CONF "/etc/mdnsd.conf"
|
||||
#define MDNSD_PID "/var/run/mdnsd.pid"
|
||||
|
||||
K_PLUGIN_FACTORY(KCMDnssdFactory, registerPlugin<KCMDnssd>();)
|
||||
K_EXPORT_PLUGIN(KCMDnssdFactory("kcmkdnssd"))
|
||||
|
||||
KCMDnssd::KCMDnssd(QWidget *parent, const QVariantList&)
|
||||
: KCModule( KCMDnssdFactory::componentData(), parent)
|
||||
{
|
||||
|
||||
widget = new Ui_ConfigDialog();
|
||||
widget->setupUi(this);
|
||||
setAboutData(new KAboutData("kcm_kdnssd", 0,
|
||||
ki18n("ZeroConf configuration"),0,KLocalizedString(),KAboutData::License_GPL,
|
||||
ki18n("(C) 2004-2007 Jakub Stachowski")));
|
||||
setQuickHelp(i18n("Setup services browsing with ZeroConf"));
|
||||
addConfig(DNSSD::Configuration::self(),this);
|
||||
setButtons( Default|Apply );
|
||||
}
|
||||
|
||||
KCMDnssd::~KCMDnssd()
|
||||
{
|
||||
}
|
||||
|
||||
void KCMDnssd::save()
|
||||
{
|
||||
KCModule::save();
|
||||
|
||||
// Send signal to all kde applications which have a DNSSD::DomainBrowserPrivate instance
|
||||
QDBusMessage message =
|
||||
QDBusMessage::createSignal("/libdnssd", "org.kde.DNSSD.DomainBrowser", "domainListChanged");
|
||||
QDBusConnection::sessionBus().send(message);
|
||||
}
|
||||
|
||||
|
||||
#include "moc_kcmdnssd.cpp"
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
/***************************************************************************
|
||||
* Copyright (C) 2004,2005 by Jakub Stachowski *
|
||||
* qbast@go2.pl *
|
||||
* *
|
||||
* 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 _KCMDNSSD_H_
|
||||
#define _KCMDNSSD_H_
|
||||
|
||||
|
||||
#include <ui_configdialog.h>
|
||||
#include <kaboutdata.h>
|
||||
#include <kcmodule.h>
|
||||
|
||||
class KCMDnssd: public KCModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KCMDnssd( QWidget *parent=0, const QVariantList& = QVariantList() );
|
||||
~KCMDnssd();
|
||||
virtual void save();
|
||||
private:
|
||||
Ui_ConfigDialog *widget;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,9 +1,2 @@
|
|||
add_definitions(
|
||||
-DQT_NO_CAST_TO_ASCII
|
||||
-DQT_NO_CAST_FROM_ASCII
|
||||
)
|
||||
|
||||
add_subdirectory( network )
|
||||
add_subdirectory( ioslave )
|
||||
add_subdirectory( kded )
|
||||
add_subdirectory( mimetypes )
|
||||
|
|
|
@ -1,37 +0,0 @@
|
|||
networkkio
|
||||
==========
|
||||
|
||||
This is an experimental kioslave which presents the network.
|
||||
It also includes a library which models the network, the devices, and services,
|
||||
and could be reused by other code.
|
||||
|
||||
Please contact the author Friedrich W. H. Kossebau <kossebau@kde.org> for any further questions.
|
||||
Cooperation in this area is welcome :)
|
||||
|
||||
|
||||
ioslave
|
||||
-------
|
||||
The ioslave lists the local network as represented by the
|
||||
The protocol name is "network", so enter "network:/" to see your local network.
|
||||
Currently, due to synchronisation problems, the network data is fetched from the
|
||||
kded network module via D-Bus, instead of using the network library directly.
|
||||
|
||||
|
||||
kded
|
||||
----
|
||||
A kded module to emit KDirNotify signals as needed if the network structure changes.
|
||||
|
||||
That way all users of the network kioslave and listening to KDirNotify can update the view,
|
||||
e.g. Dolphin, Konqueror and the KDElibs file dialogs.
|
||||
It also offers the data of the network structure over D-Bus, as currently used by the ioslave.
|
||||
|
||||
|
||||
network
|
||||
-------
|
||||
A library which models the network with all its devices and the services offered by them.
|
||||
|
||||
Currently it uses KDNSSD, the KDElibs interface to the zeroconf service discovery system,
|
||||
as the engine to find about the content of network structure. Later on this library should
|
||||
support different backends concurrently (also SLP, UPnP, Windows related stuff like smb,
|
||||
including undiscoverable/hidden but user/admin entered ones).
|
||||
If this works out this library might end in KDElibs solid module.
|
|
@ -1,27 +1,27 @@
|
|||
project( kio_network )
|
||||
project(kio_network)
|
||||
|
||||
include_directories(
|
||||
../network
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../network
|
||||
)
|
||||
|
||||
set( kio_network_SRCS
|
||||
networkdbusinterface.cpp
|
||||
networkinitwatcher.cpp
|
||||
networkthread.cpp
|
||||
networkuri.cpp
|
||||
mimetypes.cpp
|
||||
set(kio_network_SRCS
|
||||
networkslave.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# qt4_add_dbus_interface( kio_network_SRCS ../kded/org.kde.network.xml networkdbusproxy )
|
||||
kde4_add_plugin(kio_network ${kio_network_SRCS})
|
||||
|
||||
kde4_add_plugin( kio_network ${kio_network_SRCS} )
|
||||
target_link_libraries(kio_network
|
||||
${KDE4_KIO_LIBS}
|
||||
${KDE4_KDNSSD_LIBS}
|
||||
)
|
||||
|
||||
target_link_libraries( kio_network molletnetwork ${KDE4_KIO_LIBS} )
|
||||
install(
|
||||
TARGETS kio_network
|
||||
DESTINATION ${KDE4_PLUGIN_INSTALL_DIR}
|
||||
)
|
||||
|
||||
install( TARGETS kio_network DESTINATION ${KDE4_PLUGIN_INSTALL_DIR})
|
||||
|
||||
install( FILES network.protocol DESTINATION ${KDE4_SERVICES_INSTALL_DIR})
|
||||
install( FILES network.desktop DESTINATION ${KDE4_DATA_INSTALL_DIR}/remoteview)
|
||||
install(
|
||||
FILES network.protocol
|
||||
DESTINATION ${KDE4_SERVICES_INSTALL_DIR}
|
||||
)
|
||||
install(
|
||||
FILES network.desktop
|
||||
DESTINATION ${KDE4_DATA_INSTALL_DIR}/remoteview
|
||||
)
|
||||
|
|
|
@ -26,18 +26,17 @@
|
|||
#include <KComponentData>
|
||||
#include <kdemacros.h>
|
||||
// Qt
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
#include <QCoreApplication>
|
||||
|
||||
extern "C"
|
||||
{
|
||||
|
||||
int KDE_EXPORT kdemain( int argc, char** argv )
|
||||
int KDE_EXPORT kdemain(int argc, char** argv)
|
||||
{
|
||||
KComponentData componentData( "kio_network" );
|
||||
QCoreApplication app( argc, argv );
|
||||
KComponentData componentData("kio_network");
|
||||
QCoreApplication app(argc, argv);
|
||||
|
||||
NetworkSlave slave( argv[1], argv[2], argv[3] );
|
||||
NetworkSlave slave(argv[1], argv[2], argv[3]);
|
||||
slave.dispatchLoop();
|
||||
|
||||
return 0;
|
||||
|
|
|
@ -1,163 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "mimetypes.h"
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QString>
|
||||
|
||||
|
||||
const char Mimetypes::NetworkMimetype[] = "inode/vnd.kde.network";
|
||||
|
||||
// keep in sync with Mollet::NetDevice::Type
|
||||
const char* const Mimetypes::DeviceMimetype[] =
|
||||
{
|
||||
"inode/vnd.kde.device.unknown",
|
||||
"inode/vnd.kde.device.scanner",
|
||||
"inode/vnd.kde.device.printer",
|
||||
"inode/vnd.kde.device.server",
|
||||
"inode/vnd.kde.device.router",
|
||||
"inode/vnd.kde.device.workstation"
|
||||
};
|
||||
|
||||
|
||||
struct MimetypePair {
|
||||
const char* typeName;
|
||||
const char* mimetype;
|
||||
};
|
||||
|
||||
|
||||
// keep in sync with network.xml
|
||||
static const char* const SimpleServiceMimetype[] =
|
||||
{
|
||||
"ftp",
|
||||
"sftp-ssh",
|
||||
"ftps",
|
||||
"nfs",
|
||||
"afpovertcp",
|
||||
"smb",
|
||||
|
||||
"ssh",
|
||||
"telnet",
|
||||
"rfb",
|
||||
"rdp",
|
||||
|
||||
"http",
|
||||
"ntp",
|
||||
"ldap",
|
||||
|
||||
"xmpp-server",
|
||||
"presence",
|
||||
"lobby",
|
||||
"giver",
|
||||
"sip",
|
||||
"h323",
|
||||
"skype",
|
||||
|
||||
"ipp",
|
||||
"printer",
|
||||
"pdl-datastream",
|
||||
|
||||
"plasma",
|
||||
|
||||
"kbattleship",
|
||||
"lskat",
|
||||
"kfourinline",
|
||||
"ksirk",
|
||||
|
||||
"pulse-server",
|
||||
"pulse-source",
|
||||
"pulse-sink",
|
||||
"udisks-ssh",
|
||||
"libvirt",
|
||||
"airmouse",
|
||||
|
||||
"postgresql",
|
||||
"couchdb_location",
|
||||
|
||||
"realplayfavs",
|
||||
"acrobat-server",
|
||||
"adobe-vc",
|
||||
"ggz",
|
||||
|
||||
"pgpkey-ldap",
|
||||
"pgpkey-hkp",
|
||||
"pgpkey-https",
|
||||
|
||||
"maemo-inf",
|
||||
|
||||
"airport",
|
||||
"daap",
|
||||
"dacp",
|
||||
"eppc",
|
||||
"net-assistant",
|
||||
"odisk",
|
||||
"raop",
|
||||
"touch-able",
|
||||
"workstation",
|
||||
"sleep-proxy",
|
||||
"nssocketport",
|
||||
"home-sharing",
|
||||
"appletv-itunes",
|
||||
"appletv-pair",
|
||||
|
||||
"upnp.BasicDevice1",
|
||||
"upnp.WLANAccessPointDevice1",
|
||||
"upnp.InternetGatewayDevice1",
|
||||
"upnp.PrinterBasic1",
|
||||
"upnp.PrinterEnhanced1",
|
||||
"upnp.Scanner1",
|
||||
"upnp.MediaServer1",
|
||||
"upnp.MediaRenderer1",
|
||||
"upnp.MediaServer2",
|
||||
"upnp.MediaRenderer2",
|
||||
"upnp.MediaServer3",
|
||||
"upnp.SolarProtectionBlind1",
|
||||
"upnp.DigitalSecurityCamera1",
|
||||
"upnp.HVAC1",
|
||||
"upnp.LightingControls1",
|
||||
"upnp.RemoteUIClientDevice1",
|
||||
"upnp.RemoteUIServerDevice1",
|
||||
"upnp.RAClient1",
|
||||
"upnp.RAServer1",
|
||||
"upnp.RADiscoveryAgent1",
|
||||
"upnp.LANDevice1",
|
||||
"upnp.WANDevice1",
|
||||
"upnp.WANConnectionDevice1",
|
||||
"upnp.WFADevice1",
|
||||
"upnp.Unknown"
|
||||
};
|
||||
static const int SimpleServiceMimetypeCount = sizeof(SimpleServiceMimetype) / sizeof(SimpleServiceMimetype[0]);
|
||||
|
||||
QString Mimetypes::mimetypeForServiceType( const QString& serviceTypeName )
|
||||
{
|
||||
QString subType = QLatin1String("unknown");
|
||||
for( int i=0; i<SimpleServiceMimetypeCount; ++i )
|
||||
{
|
||||
if( serviceTypeName == QLatin1String(SimpleServiceMimetype[i]) )
|
||||
{
|
||||
subType = serviceTypeName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return QLatin1String("inode/vnd.kde.service.") + subType;
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef MIMETYPES_H
|
||||
#define MIMETYPES_H
|
||||
|
||||
#include <QString>
|
||||
|
||||
|
||||
class Mimetypes
|
||||
{
|
||||
public:
|
||||
static const char NetworkMimetype[];
|
||||
static const char* const DeviceMimetype[];
|
||||
|
||||
static QString mimetypeForServiceType( const QString& serviceTypeName );
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,44 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkdbusinterface.h"
|
||||
|
||||
// Qt
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
|
||||
|
||||
static const char NetworkDBusInterfaceName[] = "org.kde.network";
|
||||
|
||||
NetworkDBusInterface::NetworkDBusInterface( const QString& service, const QString& path, const QDBusConnection& connection, QObject* parent )
|
||||
: QDBusAbstractInterface( service, path, NetworkDBusInterfaceName, connection, parent )
|
||||
{
|
||||
// TODO: best place to do this?
|
||||
qDBusRegisterMetaType<Mollet::NetDevice>();
|
||||
qDBusRegisterMetaType<Mollet::NetService>();
|
||||
qDBusRegisterMetaType<Mollet::NetDeviceList>();
|
||||
qDBusRegisterMetaType<Mollet::NetServiceList>();
|
||||
}
|
||||
|
||||
NetworkDBusInterface::~NetworkDBusInterface()
|
||||
{
|
||||
}
|
||||
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKDBUSINTERFACE_H
|
||||
#define NETWORKDBUSINTERFACE_H
|
||||
|
||||
|
||||
// network
|
||||
#include <networkdbus.h>
|
||||
// Qt
|
||||
#include <QtDBus/QDBusAbstractInterface>
|
||||
#include <QtDBus/QDBusReply>
|
||||
|
||||
|
||||
// TODO: see file networkdbus.h
|
||||
class NetworkDBusInterface: public QDBusAbstractInterface
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetworkDBusInterface( const QString& service, const QString& path, const QDBusConnection& connection, QObject* parent = 0 );
|
||||
virtual ~NetworkDBusInterface();
|
||||
|
||||
public Q_SLOTS:
|
||||
QDBusReply<Mollet::NetDevice> deviceData( const QString& hostAddress );
|
||||
QDBusReply<Mollet::NetService> serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType );
|
||||
QDBusReply<Mollet::NetDeviceList> deviceDataList();
|
||||
QDBusReply<Mollet::NetServiceList> serviceDataList( const QString& hostAddress );
|
||||
};
|
||||
|
||||
// TODO: is QDBus::Block the right solution here?
|
||||
inline QDBusReply<Mollet::NetDevice> NetworkDBusInterface::deviceData( const QString& hostAddress )
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << qVariantFromValue(hostAddress);
|
||||
return callWithArgumentList( QDBus::Block, QString::fromLatin1("deviceData"), argumentList );
|
||||
}
|
||||
inline QDBusReply<Mollet::NetService> NetworkDBusInterface::serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType )
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << qVariantFromValue(hostAddress) << qVariantFromValue(serviceName) << qVariantFromValue(serviceType);
|
||||
return callWithArgumentList( QDBus::Block, QString::fromLatin1("serviceData"), argumentList );
|
||||
}
|
||||
inline QDBusReply<Mollet::NetDeviceList> NetworkDBusInterface::deviceDataList()
|
||||
{
|
||||
return call( QString::fromLatin1("deviceDataList") );
|
||||
}
|
||||
inline QDBusReply<Mollet::NetServiceList> NetworkDBusInterface::serviceDataList( const QString& hostAddress )
|
||||
{
|
||||
QList<QVariant> argumentList;
|
||||
argumentList << qVariantFromValue(hostAddress);
|
||||
return callWithArgumentList( QDBus::Block, QString::fromLatin1("serviceDataList"), argumentList );
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkinitwatcher.h"
|
|
@ -1,72 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKINITWATCHER_H
|
||||
#define NETWORKINITWATCHER_H
|
||||
|
||||
// network
|
||||
#include "network.h"
|
||||
//Qt
|
||||
#include <QtCore/QObject>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
using namespace Mollet;
|
||||
|
||||
|
||||
class NetworkInitWatcher : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetworkInitWatcher( Network* network, QMutex* mutex );
|
||||
virtual ~NetworkInitWatcher();
|
||||
|
||||
public Q_SLOTS:
|
||||
void onNetworkInitDone();
|
||||
|
||||
private:
|
||||
QMutex* mMutex;
|
||||
};
|
||||
|
||||
|
||||
inline NetworkInitWatcher::NetworkInitWatcher( Network* network, QMutex* mutex )
|
||||
: mMutex( mutex )
|
||||
{
|
||||
connect( network, SIGNAL(initDone()), SLOT(onNetworkInitDone()) );
|
||||
}
|
||||
inline NetworkInitWatcher::~NetworkInitWatcher()
|
||||
{
|
||||
kDebug();
|
||||
}
|
||||
|
||||
inline void NetworkInitWatcher::onNetworkInitDone()
|
||||
{
|
||||
kDebug()<<"before unlock";
|
||||
mMutex->unlock();
|
||||
kDebug()<<"after unlock";
|
||||
deleteLater();
|
||||
kDebug()<<"after deleteLater";
|
||||
}
|
||||
|
||||
#endif
|
|
@ -22,306 +22,82 @@
|
|||
|
||||
#include "networkslave.h"
|
||||
|
||||
// ioslave
|
||||
#include "networkuri.h"
|
||||
#include "mimetypes.h"
|
||||
#include "networkdbusinterface.h"
|
||||
// network
|
||||
#include <netdevice.h>
|
||||
#include <netservice.h>
|
||||
// KDE
|
||||
// Qt
|
||||
#include <QtCore/QEventLoop>
|
||||
#include <KDebug>
|
||||
|
||||
#include <sys/stat.h>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
// static const char NetworkIconName[] = "network-workgroup";
|
||||
|
||||
|
||||
NetworkSlave::NetworkSlave( const QByteArray& name, const QByteArray& poolSocket, const QByteArray& programSocket )
|
||||
: SlaveBase( name, poolSocket, programSocket )
|
||||
static QString mimeForService(const KDNSSDService &kdnssdservice)
|
||||
{
|
||||
kDebug();
|
||||
mNetworkDBusProxy = new NetworkDBusInterface( QLatin1String("org.kde.kded"),
|
||||
QLatin1String("/modules/networkwatcher"),
|
||||
QDBusConnection::sessionBus() );
|
||||
return QString::fromLatin1("inode/vnd.kde.service.%1").arg(
|
||||
KUrl(kdnssdservice.url).protocol()
|
||||
);
|
||||
}
|
||||
|
||||
void NetworkSlave::get( const KUrl& url )
|
||||
static QString iconForService(const KDNSSDService &kdnssdservice)
|
||||
{
|
||||
const NetworkUri networkUri( url );
|
||||
|
||||
bool successfulGetting = false;
|
||||
|
||||
const NetworkUri::Type type = networkUri.type();
|
||||
kDebug()<<"type="<<networkUri.type()<<"host="<<networkUri.hostAddress()<<"service="<<networkUri.serviceName()<<"stype="<<networkUri.serviceType();
|
||||
if( type == NetworkUri::Service )
|
||||
{
|
||||
const QString hostAddress = networkUri.hostAddress();
|
||||
const QString serviceName = networkUri.serviceName();
|
||||
const QString serviceType = networkUri.serviceType();
|
||||
QDBusReply<Mollet::NetService> reply = mNetworkDBusProxy->serviceData( hostAddress, serviceName, serviceType );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetService serviceData = reply.value();
|
||||
if( serviceData.isValid() )
|
||||
{
|
||||
const QString url = serviceData.url();
|
||||
redirection( url );
|
||||
finished();
|
||||
successfulGetting = true;
|
||||
}
|
||||
}
|
||||
if (kdnssdservice.url.startsWith(QLatin1String("rfb://"))) {
|
||||
return QString::fromLatin1("krfb");
|
||||
}
|
||||
|
||||
if( ! successfulGetting )
|
||||
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
|
||||
return QString::fromLatin1("network-workgroup");
|
||||
}
|
||||
|
||||
void NetworkSlave::mimetype( const KUrl& url )
|
||||
NetworkSlave::NetworkSlave(const QByteArray &name, const QByteArray &poolSocket, const QByteArray &programSocket)
|
||||
: SlaveBase(name, poolSocket, programSocket)
|
||||
{
|
||||
const NetworkUri networkUri( url );
|
||||
|
||||
bool successfulMimetyping = false;
|
||||
NetworkUri::Type type = networkUri.type();
|
||||
kDebug()<<"type="<<networkUri.type()<<"host="<<networkUri.hostAddress()<<"service="<<networkUri.serviceName()<<"stype="<<networkUri.serviceType();
|
||||
|
||||
if( type == NetworkUri::Domain )
|
||||
{
|
||||
mimeType( QLatin1String(Mimetypes::NetworkMimetype) );
|
||||
finished();
|
||||
successfulMimetyping = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString hostAddress = networkUri.hostAddress();
|
||||
if( type == NetworkUri::Device )
|
||||
{
|
||||
QDBusReply<Mollet::NetDevice> reply = mNetworkDBusProxy->deviceData( hostAddress );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetDevice deviceData = reply.value();
|
||||
|
||||
mimeType( QLatin1String(Mimetypes::DeviceMimetype[deviceData.type()]) );
|
||||
finished();
|
||||
successfulMimetyping = true;
|
||||
}
|
||||
}
|
||||
else if( type == NetworkUri::Service )
|
||||
{
|
||||
const QString serviceName = networkUri.serviceName();
|
||||
const QString serviceType = networkUri.serviceType();
|
||||
QDBusReply<Mollet::NetService> reply = mNetworkDBusProxy->serviceData( hostAddress, serviceName, serviceType );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetService serviceData = reply.value();
|
||||
if( serviceData.isValid() )
|
||||
{
|
||||
const QString url = serviceData.url();
|
||||
redirection( url );
|
||||
//mimeType( Mimetypes::mimetypeForServiceType(serviceData.type()) );
|
||||
finished();
|
||||
successfulMimetyping = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !successfulMimetyping )
|
||||
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
|
||||
}
|
||||
|
||||
|
||||
void NetworkSlave::stat( const KUrl& url )
|
||||
{
|
||||
const NetworkUri networkUri( url );
|
||||
|
||||
bool successfulStating = false;
|
||||
NetworkUri::Type type = networkUri.type();
|
||||
kDebug()<<"type="<<networkUri.type()<<"host="<<networkUri.hostAddress()<<"service="<<networkUri.serviceName()<<"stype="<<networkUri.serviceType();
|
||||
|
||||
if( type == NetworkUri::Domain )
|
||||
{
|
||||
KIO::UDSEntry entry;
|
||||
feedEntryAsNetwork( &entry );
|
||||
statEntry( entry );
|
||||
finished();
|
||||
successfulStating = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString hostAddress = networkUri.hostAddress();
|
||||
if( type == NetworkUri::Device )
|
||||
{
|
||||
QDBusReply<Mollet::NetDevice> reply = mNetworkDBusProxy->deviceData( hostAddress );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetDevice deviceData = reply.value();
|
||||
|
||||
KIO::UDSEntry entry;
|
||||
feedEntryAsDevice( &entry, deviceData );
|
||||
statEntry( entry );
|
||||
finished();
|
||||
successfulStating = true;
|
||||
}
|
||||
}
|
||||
else if( type == NetworkUri::Service )
|
||||
{
|
||||
const QString serviceName = networkUri.serviceName();
|
||||
const QString serviceType = networkUri.serviceType();
|
||||
QDBusReply<Mollet::NetService> reply = mNetworkDBusProxy->serviceData( hostAddress, serviceName, serviceType );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetService serviceData = reply.value();
|
||||
if( serviceData.isValid() )
|
||||
{
|
||||
const QString url = serviceData.url();
|
||||
redirection( url );
|
||||
//KIO::UDSEntry entry;
|
||||
//feedEntryAsService( &entry, serviceData );
|
||||
//statEntry( entry );
|
||||
finished();
|
||||
successfulStating = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( !successfulStating )
|
||||
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
|
||||
}
|
||||
|
||||
void NetworkSlave::listDir( const KUrl& url )
|
||||
{
|
||||
const NetworkUri networkUri( url );
|
||||
|
||||
bool successfulListing = false;
|
||||
NetworkUri::Type networkUriType = networkUri.type();
|
||||
kDebug()<<"type="<<networkUri.type()<<"host="<<networkUri.hostAddress()<<"service="<<networkUri.serviceName()<<"stype="<<networkUri.serviceType();
|
||||
|
||||
if( networkUriType != NetworkUri::InvalidUrl )
|
||||
{
|
||||
if( networkUriType == NetworkUri::Domain )
|
||||
{
|
||||
QDBusReply<Mollet::NetDeviceList> reply = mNetworkDBusProxy->deviceDataList();
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetDeviceList deviceDataList = reply.value();
|
||||
|
||||
foreach( const Mollet::NetDevice& deviceData, deviceDataList )
|
||||
{
|
||||
KIO::UDSEntry entry;
|
||||
feedEntryAsDevice( &entry, deviceData );
|
||||
listEntry( entry, false );
|
||||
}
|
||||
KIO::UDSEntry entry;
|
||||
listEntry( entry, true );
|
||||
finished();
|
||||
successfulListing = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
const QString hostAddress = networkUri.hostAddress();
|
||||
if( networkUriType == NetworkUri::Device )
|
||||
{
|
||||
QDBusReply<Mollet::NetServiceList> reply = mNetworkDBusProxy->serviceDataList( hostAddress );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetServiceList serviceDataList = reply.value();
|
||||
|
||||
foreach( const Mollet::NetService& serviceData, serviceDataList )
|
||||
{
|
||||
KIO::UDSEntry entry;
|
||||
feedEntryAsService( &entry, serviceData );
|
||||
listEntry( entry, false );
|
||||
}
|
||||
KIO::UDSEntry entry;
|
||||
listEntry( entry, true );
|
||||
finished();
|
||||
successfulListing = true;
|
||||
}
|
||||
}
|
||||
else if( networkUriType == NetworkUri::Service )
|
||||
{
|
||||
const QString serviceName = networkUri.serviceName();
|
||||
const QString serviceType = networkUri.serviceType();
|
||||
QDBusReply<Mollet::NetService> reply = mNetworkDBusProxy->serviceData( hostAddress, serviceName, serviceType );
|
||||
|
||||
kDebug()<<reply.isValid();
|
||||
if( reply.isValid() ) // TODO: find how a not found service can be expressed in the reply
|
||||
{
|
||||
Mollet::NetService serviceData = reply.value();
|
||||
if( serviceData.isValid() )
|
||||
{
|
||||
const QString url = serviceData.url();
|
||||
redirection( url );
|
||||
finished();
|
||||
successfulListing = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ! successfulListing )
|
||||
error( KIO::ERR_DOES_NOT_EXIST, url.prettyUrl() );
|
||||
}
|
||||
|
||||
|
||||
void NetworkSlave::feedEntryAsNetwork( KIO::UDSEntry* entry )
|
||||
{
|
||||
entry->insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
|
||||
// entry->insert( KIO::UDSEntry::UDS_ICON_NAME, NetworkIconName );
|
||||
entry->insert( KIO::UDSEntry::UDS_MIME_TYPE, QLatin1String(Mimetypes::NetworkMimetype) );
|
||||
|
||||
}
|
||||
|
||||
void NetworkSlave::feedEntryAsDevice( KIO::UDSEntry* entry, const Mollet::NetDevice& deviceData )
|
||||
{
|
||||
entry->insert( KIO::UDSEntry::UDS_NAME, deviceData.hostAddress() );
|
||||
entry->insert( KIO::UDSEntry::UDS_DISPLAY_NAME, deviceData.name() );
|
||||
entry->insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFDIR );
|
||||
// entry->insert( KIO::UDSEntry::UDS_ICON_NAME, NetDevice::iconName(deviceData.type()) );
|
||||
entry->insert( KIO::UDSEntry::UDS_MIME_TYPE, QLatin1String(Mimetypes::DeviceMimetype[deviceData.type()]) );
|
||||
|
||||
}
|
||||
|
||||
void NetworkSlave::feedEntryAsService( KIO::UDSEntry* entry, const Mollet::NetService& serviceData )
|
||||
{
|
||||
entry->insert( KIO::UDSEntry::UDS_NAME, serviceData.name()+QLatin1Char('.')+serviceData.type() );
|
||||
entry->insert( KIO::UDSEntry::UDS_DISPLAY_NAME, serviceData.name() );
|
||||
entry->insert( KIO::UDSEntry::UDS_FILE_TYPE, S_IFLNK );
|
||||
entry->insert( KIO::UDSEntry::UDS_ACCESS, S_IRWXU|S_IRWXG|S_IRWXO );
|
||||
entry->insert( KIO::UDSEntry::UDS_ICON_NAME, serviceData.iconName() );
|
||||
entry->insert( KIO::UDSEntry::UDS_MIME_TYPE, Mimetypes::mimetypeForServiceType(serviceData.type()) );
|
||||
if( !serviceData.url().isEmpty() )
|
||||
entry->insert( KIO::UDSEntry::UDS_TARGET_URL, serviceData.url() );
|
||||
}
|
||||
|
||||
void NetworkSlave::reportError( const NetworkUri& networkUri, int errorId )
|
||||
{
|
||||
Q_UNUSED( networkUri )
|
||||
Q_UNUSED( errorId )
|
||||
}
|
||||
|
||||
NetworkSlave::~NetworkSlave()
|
||||
{
|
||||
delete mNetworkDBusProxy;
|
||||
}
|
||||
|
||||
void NetworkSlave::mimetype(const KUrl &url)
|
||||
{
|
||||
foreach (const KDNSSDService &kdnssdservice, m_kdnssd.services()) {
|
||||
// qDebug() << Q_FUNC_INFO << kdnssdservice.url << url.prettyUrl();
|
||||
if (kdnssdservice.url == url.prettyUrl()) {
|
||||
mimeType(mimeForService(kdnssdservice));
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
error(KIO::ERR_DOES_NOT_EXIST, url.prettyUrl());
|
||||
}
|
||||
|
||||
void NetworkSlave::stat(const KUrl &url)
|
||||
{
|
||||
m_kdnssd.startBrowse();
|
||||
foreach (const KDNSSDService &kdnssdservice, m_kdnssd.services()) {
|
||||
// qDebug() << Q_FUNC_INFO << kdnssdservice.url << url.prettyUrl();
|
||||
if (kdnssdservice.url == url.prettyUrl()) {
|
||||
KIO::UDSEntry kioudsentry;
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_NAME, kdnssdservice.name);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFLNK);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_ICON_NAME, iconForService(kdnssdservice));
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_MIME_TYPE, mimeForService(kdnssdservice));
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_TARGET_URL, kdnssdservice.url);
|
||||
statEntry(kioudsentry);
|
||||
finished();
|
||||
return;
|
||||
}
|
||||
}
|
||||
error(KIO::ERR_DOES_NOT_EXIST, url.prettyUrl());
|
||||
}
|
||||
|
||||
void NetworkSlave::listDir(const KUrl &url)
|
||||
{
|
||||
m_kdnssd.startBrowse();
|
||||
KIO::UDSEntry kioudsentry;
|
||||
foreach (const KDNSSDService &kdnssdservice, m_kdnssd.services()) {
|
||||
kioudsentry.clear();
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_NAME, kdnssdservice.name);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_FILE_TYPE, S_IFLNK);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_ACCESS, S_IRWXU | S_IRWXG | S_IRWXO);
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_ICON_NAME, iconForService(kdnssdservice));
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_MIME_TYPE, mimeForService(kdnssdservice));
|
||||
kioudsentry.insert(KIO::UDSEntry::UDS_TARGET_URL, kdnssdservice.url);
|
||||
listEntry(kioudsentry, false);
|
||||
}
|
||||
listEntry(kioudsentry, true);
|
||||
finished();
|
||||
}
|
||||
|
|
|
@ -25,38 +25,21 @@
|
|||
|
||||
// KDE
|
||||
#include <KIO/SlaveBase>
|
||||
|
||||
class NetworkDBusInterface;
|
||||
class NetworkUri;
|
||||
namespace Mollet {
|
||||
class NetDevice;
|
||||
class NetService;
|
||||
}
|
||||
namespace KIO {
|
||||
class UDSEntry;
|
||||
}
|
||||
#include <kdnssd.h>
|
||||
|
||||
class NetworkSlave : public KIO::SlaveBase
|
||||
{
|
||||
public:
|
||||
NetworkSlave( const QByteArray& name, const QByteArray& poolSocket, const QByteArray& programSocket );
|
||||
public:
|
||||
NetworkSlave(const QByteArray &name, const QByteArray &poolSocket, const QByteArray &programSocket);
|
||||
virtual ~NetworkSlave();
|
||||
|
||||
public: // KIO::SlaveBase API
|
||||
virtual void mimetype( const KUrl& url );
|
||||
virtual void get( const KUrl& url );
|
||||
virtual void stat( const KUrl& url );
|
||||
virtual void listDir( const KUrl& url );
|
||||
public: // KIO::SlaveBase API
|
||||
virtual void mimetype(const KUrl &url);
|
||||
virtual void stat(const KUrl &url);
|
||||
virtual void listDir(const KUrl &url);
|
||||
|
||||
private:
|
||||
void feedEntryAsNetwork( KIO::UDSEntry* entry );
|
||||
void feedEntryAsDevice( KIO::UDSEntry* entry, const Mollet::NetDevice& deviceData );
|
||||
void feedEntryAsService( KIO::UDSEntry* entry, const Mollet::NetService& serviceData );
|
||||
|
||||
void reportError( const NetworkUri& networkUri, int errorId );
|
||||
|
||||
private: // data
|
||||
NetworkDBusInterface* mNetworkDBusProxy;
|
||||
private: // data
|
||||
KDNSSD m_kdnssd;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,92 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkthread.h"
|
||||
|
||||
// ioslave
|
||||
#include "networkinitwatcher.h"
|
||||
// network
|
||||
#include "network.h"
|
||||
#include "netdevice.h"
|
||||
#include "netservice.h"
|
||||
//Qt
|
||||
#include <QtCore/QCoreApplication>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
NetworkThread::NetworkThread()
|
||||
: QThread()
|
||||
, mNetwork( 0 )
|
||||
, mContinue( true )
|
||||
{
|
||||
}
|
||||
|
||||
Mollet::Network* NetworkThread::network() const { return mNetwork; }
|
||||
|
||||
void NetworkThread::pause()
|
||||
{
|
||||
kDebug()<<"before lock";
|
||||
mMutex.lock();
|
||||
kDebug()<<"after lock";
|
||||
exit();
|
||||
kDebug()<<"after exit";
|
||||
}
|
||||
|
||||
|
||||
void NetworkThread::unpause()
|
||||
{
|
||||
kDebug()<<"before unlock";
|
||||
mMutex.unlock();
|
||||
kDebug()<<"after unlock";
|
||||
}
|
||||
|
||||
void NetworkThread::finish()
|
||||
{
|
||||
mContinue = false;
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
void NetworkThread::run()
|
||||
{
|
||||
mNetwork = Mollet::Network::network();
|
||||
|
||||
kDebug()<<"starting with lock";
|
||||
mMutex.lock();
|
||||
new NetworkInitWatcher( mNetwork, &mMutex );
|
||||
|
||||
do
|
||||
{
|
||||
kDebug()<<"going exec()";
|
||||
exec();
|
||||
kDebug()<<"left exec()";
|
||||
mMutex.lock();
|
||||
kDebug()<<"after lock";
|
||||
mMutex.unlock();
|
||||
kDebug()<<"after unlock";
|
||||
}
|
||||
while( mContinue );
|
||||
}
|
||||
|
||||
NetworkThread::~NetworkThread()
|
||||
{
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKTHREAD_H
|
||||
#define NETWORKTHREAD_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QThread>
|
||||
#include <QtCore/QMutex>
|
||||
|
||||
namespace Mollet {
|
||||
class Network;
|
||||
}
|
||||
|
||||
|
||||
class NetworkThread : public QThread
|
||||
{
|
||||
public:
|
||||
NetworkThread();
|
||||
virtual ~NetworkThread();
|
||||
|
||||
public:
|
||||
Mollet::Network* network() const;
|
||||
|
||||
public:
|
||||
void pause();
|
||||
void unpause();
|
||||
void finish();
|
||||
|
||||
protected: // QThread API
|
||||
virtual void run();
|
||||
|
||||
private:
|
||||
QMutex mMutex;
|
||||
Mollet::Network* mNetwork;
|
||||
|
||||
bool mContinue;
|
||||
};
|
||||
|
||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkuri.h"
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKURI_H
|
||||
#define NETWORKURI_H
|
||||
|
||||
// KDE
|
||||
#include <KUrl>
|
||||
// // Qt
|
||||
// #include <QtCore/QDataStream>
|
||||
|
||||
|
||||
// network://domain/hostname/servicename
|
||||
class NetworkUri
|
||||
{
|
||||
// friend QDataStream& operator<<( QDataStream& stream, const NetworkUri& networkUri );
|
||||
|
||||
public:
|
||||
enum Type { InvalidUrl, Domain, Device, Service };
|
||||
public:
|
||||
explicit NetworkUri( const KUrl& url );
|
||||
|
||||
public:
|
||||
const QString& hostAddress() const;
|
||||
const QString& serviceName() const;
|
||||
const QString& serviceType() const;
|
||||
NetworkUri::Type type() const;
|
||||
|
||||
private:
|
||||
|
||||
private: // data
|
||||
QString mHostAddress;
|
||||
QString mServiceName;
|
||||
QString mServiceType;
|
||||
};
|
||||
|
||||
|
||||
inline NetworkUri::NetworkUri( const KUrl& url )
|
||||
{
|
||||
mHostAddress = url.path().mid( 1 );
|
||||
const int slashIndex = mHostAddress.indexOf( QLatin1Char('/') );
|
||||
if( slashIndex != -1 )
|
||||
{
|
||||
// servicetype is currently appended as .type to the name
|
||||
const int serviceTypeIndex = mHostAddress.lastIndexOf( QLatin1Char('.') ) + 1;
|
||||
mServiceType = mHostAddress.mid( serviceTypeIndex );
|
||||
|
||||
const int serviceNameLength = (serviceTypeIndex-1) - (slashIndex+1);
|
||||
mServiceName = mHostAddress.mid( slashIndex + 1, serviceNameLength );
|
||||
mHostAddress.resize( slashIndex );
|
||||
}
|
||||
}
|
||||
|
||||
inline const QString& NetworkUri::hostAddress() const { return mHostAddress; }
|
||||
inline const QString& NetworkUri::serviceName() const { return mServiceName; }
|
||||
inline const QString& NetworkUri::serviceType() const { return mServiceType; }
|
||||
|
||||
inline NetworkUri::Type NetworkUri::type() const
|
||||
{
|
||||
Type result =
|
||||
mHostAddress.isEmpty() ? Domain :
|
||||
mServiceName.isEmpty() ? Device :
|
||||
/*else*/ Service;
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/*
|
||||
inline QDataStream& operator<<( QDataStream& stream, const NetworkUri& networkUri )
|
||||
{
|
||||
stream << "NetworkUri(host:"<<networkUri.mHostAddress
|
||||
<< ",service:"<<networkUri.mServiceName
|
||||
<< ",type:"<<static_cast<int>(networkUri.type())<<")";
|
||||
return stream;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
|
@ -1,24 +0,0 @@
|
|||
project( networkwatcher )
|
||||
|
||||
include_directories(
|
||||
../network
|
||||
${CMAKE_CURRENT_BINARY_DIR}/../network
|
||||
../ioslave
|
||||
)
|
||||
set( kded_networkwatcher_SRCS
|
||||
networkdbusadaptor.cpp
|
||||
kioslavenotifier.cpp
|
||||
networkwatcher.cpp
|
||||
main.cpp
|
||||
)
|
||||
|
||||
qt4_add_dbus_adaptor( kded_networkwatcher_SRCS org.kde.network.kioslavenotifier.xml kioslavenotifier.h Mollet::KioSlaveNotifier )
|
||||
|
||||
kde4_add_plugin( kded_networkwatcher ${kded_networkwatcher_SRCS} )
|
||||
|
||||
target_link_libraries( kded_networkwatcher ${KDE4_KIO_LIBS} molletnetwork )
|
||||
|
||||
install( TARGETS kded_networkwatcher DESTINATION ${KDE4_PLUGIN_INSTALL_DIR} )
|
||||
|
||||
install( FILES networkwatcher.desktop DESTINATION ${KDE4_SERVICES_INSTALL_DIR}/kded )
|
||||
install( FILES org.kde.network.kioslavenotifier.xml DESTINATION ${KDE4_DBUS_INTERFACES_INSTALL_DIR} )
|
|
@ -1,208 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "kioslavenotifier.h"
|
||||
|
||||
// module
|
||||
#include "kioslavenotifieradaptor.h"
|
||||
// kioslave
|
||||
#include <networkuri.h>
|
||||
// network
|
||||
#include <network.h>
|
||||
#include <netdevice.h>
|
||||
#include <netservice.h>
|
||||
// KDE
|
||||
#include <kdirnotify.h>
|
||||
// Qt
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
static inline QString idFrom( const NetworkUri& networkUri )
|
||||
{
|
||||
return networkUri.hostAddress().isEmpty() ? QString() :
|
||||
networkUri.serviceName().isEmpty() ? networkUri.hostAddress() :
|
||||
/*else*/ networkUri.hostAddress()+QLatin1Char('/')+networkUri.serviceName();
|
||||
}
|
||||
|
||||
static inline QString dirIdFor( const NetDevice& device )
|
||||
{
|
||||
Q_UNUSED( device )
|
||||
return QString();
|
||||
}
|
||||
static inline QString pathFor( const NetDevice& device )
|
||||
{
|
||||
return device.hostAddress();
|
||||
}
|
||||
|
||||
static inline QString dirIdFor( const NetService& service )
|
||||
{
|
||||
return service.device().hostAddress();
|
||||
}
|
||||
|
||||
static inline QString pathFor( const NetService& service )
|
||||
{
|
||||
return service.device().hostAddress() + QLatin1Char('/') + service.name()+QLatin1Char('.')+service.type();
|
||||
}
|
||||
|
||||
|
||||
KioSlaveNotifier::KioSlaveNotifier( Network* network, QObject* parent )
|
||||
: QObject( parent )
|
||||
{
|
||||
QDBusConnection sessionBus = QDBusConnection::sessionBus();
|
||||
const QString allServices;
|
||||
const QString allPaths;
|
||||
const QString interface = QLatin1String( "org.kde.KDirNotify" );
|
||||
sessionBus.connect( allServices, allPaths, interface, QLatin1String("enteredDirectory"),
|
||||
this, SLOT(onDirectoryEntered(QString)) );
|
||||
sessionBus.connect( allServices, allPaths, interface, QLatin1String("leftDirectory"),
|
||||
this, SLOT(onDirectoryLeft(QString)) );
|
||||
|
||||
new KioSlaveNotifierAdaptor( this );
|
||||
|
||||
connect( network, SIGNAL(devicesAdded(QList<NetDevice>)), SLOT(onDevicesAdded(QList<NetDevice>)) );
|
||||
connect( network, SIGNAL(devicesRemoved(QList<NetDevice>)), SLOT(onDevicesRemoved(QList<NetDevice>)) );
|
||||
connect( network, SIGNAL(servicesAdded(QList<NetService>)), SLOT(onServicesAdded(QList<NetService>)) );
|
||||
connect( network, SIGNAL(servicesRemoved(QList<NetService>)), SLOT(onServicesRemoved(QList<NetService>)) );
|
||||
}
|
||||
|
||||
QStringList KioSlaveNotifier::watchedDirectories() const
|
||||
{
|
||||
return mWatchedDirs.keys();
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::onDirectoryEntered( const QString& directory )
|
||||
{
|
||||
kDebug()<<directory;
|
||||
if( !directory.startsWith(QLatin1String("network:/")) )
|
||||
return;
|
||||
|
||||
const NetworkUri networkUri( directory );
|
||||
const QString id = idFrom( networkUri );
|
||||
|
||||
QHash<QString, int>::Iterator it = mWatchedDirs.find( id );
|
||||
|
||||
if( it == mWatchedDirs.end() )
|
||||
{
|
||||
const QString id = idFrom( networkUri );
|
||||
mWatchedDirs.insert( id, 1 );
|
||||
}
|
||||
else
|
||||
*it++;
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::onDirectoryLeft( const QString& directory )
|
||||
{
|
||||
kDebug()<<directory;
|
||||
if( !directory.startsWith(QLatin1String("network:/")) )
|
||||
return;
|
||||
|
||||
const NetworkUri networkUri( directory );
|
||||
const QString id = idFrom( networkUri );
|
||||
|
||||
QHash<QString, int>::Iterator it = mWatchedDirs.find( id );
|
||||
|
||||
if( it == mWatchedDirs.end() )
|
||||
return;
|
||||
|
||||
if( *it == 1 )
|
||||
mWatchedDirs.erase( it );
|
||||
else
|
||||
*it--;
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::notifyAboutAdded( const QString& dirId )
|
||||
{
|
||||
QHash<QString, int>::Iterator it = mWatchedDirs.find( dirId );
|
||||
if( it != mWatchedDirs.end() )
|
||||
{
|
||||
const QString url = QLatin1String("network:/") + dirId;
|
||||
kDebug()<<url;
|
||||
org::kde::KDirNotify::emitFilesAdded( url );
|
||||
}
|
||||
}
|
||||
|
||||
void KioSlaveNotifier::notifyAboutRemoved( const QString& dirId, const QString& itemPath )
|
||||
{
|
||||
QHash<QString, int>::Iterator it = mWatchedDirs.find( dirId );
|
||||
if( it != mWatchedDirs.end() )
|
||||
{
|
||||
QStringList itemUrls;
|
||||
itemUrls.append( QLatin1String("network:/") + itemPath );
|
||||
kDebug()<<itemUrls;
|
||||
org::kde::KDirNotify::emitFilesRemoved( itemUrls );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::onDevicesAdded( const QList<NetDevice>& deviceList )
|
||||
{
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
const QString id = dirIdFor( device );
|
||||
notifyAboutAdded( id );
|
||||
}
|
||||
}
|
||||
|
||||
void KioSlaveNotifier::onDevicesRemoved( const QList<NetDevice>& deviceList )
|
||||
{
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
const QString dirId = dirIdFor( device );
|
||||
const QString itemPath = pathFor( device );
|
||||
notifyAboutRemoved( dirId, itemPath );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::onServicesAdded( const QList<NetService>& serviceList )
|
||||
{
|
||||
foreach( const NetService& service, serviceList )
|
||||
{
|
||||
const QString id = dirIdFor( service );
|
||||
notifyAboutAdded( id );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KioSlaveNotifier::onServicesRemoved( const QList<NetService>& serviceList )
|
||||
{
|
||||
foreach( const NetService& service, serviceList )
|
||||
{
|
||||
const QString dirId = dirIdFor( service );
|
||||
const QString itemPath = pathFor( service );
|
||||
notifyAboutRemoved( dirId, itemPath );
|
||||
}
|
||||
}
|
||||
|
||||
KioSlaveNotifier::~KioSlaveNotifier()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef KIOSLAVENOTIFIER_H
|
||||
#define KIOSLAVENOTIFIER_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QHash>
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class Network;
|
||||
class NetDevice;
|
||||
class NetService;
|
||||
|
||||
|
||||
class KioSlaveNotifier : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit KioSlaveNotifier( Network* network, QObject* parent = 0 );
|
||||
virtual ~KioSlaveNotifier();
|
||||
|
||||
public: // for debugging, remove also from adaptor.xml
|
||||
QStringList watchedDirectories() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void onDirectoryEntered( const QString& directory );
|
||||
void onDirectoryLeft( const QString& directory );
|
||||
|
||||
private:
|
||||
void notifyAboutAdded( const QString& dirId );
|
||||
void notifyAboutRemoved( const QString& dirId, const QString& itemPath );
|
||||
|
||||
private Q_SLOTS:
|
||||
void onDevicesAdded( const QList<NetDevice>& deviceList );
|
||||
void onDevicesRemoved( const QList<NetDevice>& deviceList );
|
||||
void onServicesAdded( const QList<NetService>& serviceList );
|
||||
void onServicesRemoved( const QList<NetService>& serviceList );
|
||||
|
||||
private:
|
||||
QHash<QString, int> mWatchedDirs;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,32 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkwatcher.h"
|
||||
|
||||
// KDE
|
||||
#include <KPluginFactory>
|
||||
#include <KPluginLoader>
|
||||
|
||||
|
||||
K_PLUGIN_FACTORY( NetworkWatcherFactory, registerPlugin<Mollet::NetworkWatcher>(); )
|
||||
|
||||
K_EXPORT_PLUGIN( NetworkWatcherFactory("networkwatcher") )
|
|
@ -1,65 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkdbusadaptor.h"
|
||||
|
||||
// network
|
||||
#include <networkdbus.h>
|
||||
// Qt
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
NetworkDBusAdaptor::NetworkDBusAdaptor( NetworkWatcher* parent )
|
||||
: QDBusAbstractAdaptor( parent )
|
||||
{
|
||||
// TODO: best place to do this?
|
||||
qDBusRegisterMetaType<Mollet::NetDevice>();
|
||||
qDBusRegisterMetaType<Mollet::NetService>();
|
||||
qDBusRegisterMetaType<Mollet::NetDeviceList>();
|
||||
qDBusRegisterMetaType<Mollet::NetServiceList>();
|
||||
}
|
||||
|
||||
NetDevice NetworkDBusAdaptor::deviceData( const QString& hostAddress )
|
||||
{
|
||||
return parent()->deviceData( hostAddress );
|
||||
}
|
||||
NetService NetworkDBusAdaptor::serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType )
|
||||
{
|
||||
return parent()->serviceData( hostAddress, serviceName, serviceType );
|
||||
}
|
||||
NetDeviceList NetworkDBusAdaptor::deviceDataList()
|
||||
{
|
||||
return parent()->deviceDataList();
|
||||
}
|
||||
NetServiceList NetworkDBusAdaptor::serviceDataList( const QString& hostAddress )
|
||||
{
|
||||
return parent()->serviceDataList( hostAddress );
|
||||
}
|
||||
|
||||
NetworkDBusAdaptor::~NetworkDBusAdaptor()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKDBUSADAPTOR_H
|
||||
#define NETWORKDBUSADAPTOR_H
|
||||
|
||||
// kded
|
||||
#include "networkwatcher.h"
|
||||
//
|
||||
#include <networkdbus.h>
|
||||
// Qt
|
||||
#include <QtCore/QObject>
|
||||
#include <QtDBus/QtDBus>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
// TODO: see file networkdbus.h
|
||||
class NetworkDBusAdaptor: public QDBusAbstractAdaptor
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_CLASSINFO("D-Bus Interface", "org.kde.network")
|
||||
|
||||
public:
|
||||
explicit NetworkDBusAdaptor( NetworkWatcher* parent );
|
||||
virtual ~NetworkDBusAdaptor();
|
||||
|
||||
public:
|
||||
NetworkWatcher* parent() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
Mollet::NetDevice deviceData( const QString& hostAddress );
|
||||
Mollet::NetService serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType );
|
||||
Mollet::NetDeviceList deviceDataList();
|
||||
Mollet::NetServiceList serviceDataList( const QString& hostAddress );
|
||||
};
|
||||
|
||||
|
||||
inline NetworkWatcher* NetworkDBusAdaptor::parent() const { return static_cast<NetworkWatcher*>( QObject::parent() ); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,118 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkwatcher.h"
|
||||
|
||||
// module
|
||||
#include "networkdbusadaptor.h"
|
||||
#include "kioslavenotifier.h"
|
||||
// network
|
||||
#include <network.h>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
NetworkWatcher::NetworkWatcher( QObject* parent, const QList<QVariant>& parameters )
|
||||
: KDEDModule( parent )
|
||||
{
|
||||
Q_UNUSED( parameters )
|
||||
mNetwork = Network::network();
|
||||
|
||||
new KioSlaveNotifier( mNetwork );
|
||||
|
||||
new NetworkDBusAdaptor( this );
|
||||
QDBusConnection::sessionBus().registerService( QString::fromLatin1("org.kde.kded") );
|
||||
QDBusConnection::sessionBus().registerObject( QString::fromLatin1("/modules/networkwatcher"), this );
|
||||
}
|
||||
|
||||
// TODO: instead use networkuri and return QVariant for all these
|
||||
NetDevice NetworkWatcher::deviceData( const QString& hostAddress )
|
||||
{
|
||||
NetDevice result;
|
||||
|
||||
const QList<NetDevice> deviceList = mNetwork->deviceList();
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
if( device.hostAddress() == hostAddress )
|
||||
{
|
||||
result = device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NetService NetworkWatcher::serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType )
|
||||
{
|
||||
NetService result;
|
||||
|
||||
const QList<NetDevice> deviceList = mNetwork->deviceList();
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
if( device.hostAddress() == hostAddress )
|
||||
{
|
||||
const QList<NetService> serviceList = device.serviceList();
|
||||
|
||||
foreach( const NetService& service, serviceList )
|
||||
{
|
||||
if( service.name() == serviceName && service.type() == serviceType )
|
||||
{
|
||||
result = service;
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NetDeviceList NetworkWatcher::deviceDataList()
|
||||
{
|
||||
return mNetwork->deviceList();
|
||||
}
|
||||
|
||||
NetServiceList NetworkWatcher::serviceDataList( const QString& hostAddress )
|
||||
{
|
||||
NetServiceList result;
|
||||
|
||||
const QList<NetDevice> deviceList = mNetwork->deviceList();
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
if( device.hostAddress() == hostAddress )
|
||||
{
|
||||
result = device.serviceList();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NetworkWatcher::~NetworkWatcher()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,148 +0,0 @@
|
|||
[Desktop Entry]
|
||||
Type=Service
|
||||
X-KDE-ServiceTypes=KDEDModule
|
||||
X-KDE-Library=networkwatcher
|
||||
X-KDE-DBus-ModuleName=networkwatcher
|
||||
X-KDE-Kded-autoload=false
|
||||
X-KDE-Kded-load-on-demand=true
|
||||
Name=Network Watcher
|
||||
Name[ar]=مراقب الشبكة
|
||||
Name[ast]=Visor de redes
|
||||
Name[bg]=Наблюдение на мрежата
|
||||
Name[bn]=নেটওয়ার্ক ওয়াচার
|
||||
Name[bs]=Nadzornik mreže
|
||||
Name[ca]=Vigilant de la xarxa
|
||||
Name[ca@valencia]=Vigilant de la xarxa
|
||||
Name[cs]=Sledování sítě
|
||||
Name[csb]=Dozérôcz sécë
|
||||
Name[da]=Netværksovervåger
|
||||
Name[de]=Netzwerküberwachung
|
||||
Name[el]=Επόπτης δικτύων
|
||||
Name[en_GB]=Network Watcher
|
||||
Name[eo]=Kontrolilo de reto
|
||||
Name[es]=Observador de redes
|
||||
Name[et]=Võrgujälgija
|
||||
Name[eu]=Sare-behatzailea
|
||||
Name[fa]=دیدهبان شبکه
|
||||
Name[fi]=Verkkotilan valvoja
|
||||
Name[fr]=Surveillance du réseau
|
||||
Name[fy]=Netwurk sjogger
|
||||
Name[ga]=Fairtheoir Líonra
|
||||
Name[gl]=Vixilante da rede
|
||||
Name[gu]=નેટવર્ક દેખરેખ
|
||||
Name[he]=מנטר הרשת
|
||||
Name[hi]=नेटवर्क चौकीदार
|
||||
Name[hr]=Nadzornik mreže
|
||||
Name[hu]=Hálózatfigyelő
|
||||
Name[ia]=Observator de Rete
|
||||
Name[id]=Pengawas Jaringan
|
||||
Name[is]=Netskoðunartól
|
||||
Name[it]=Guardia di rete
|
||||
Name[ja]=ネットワークウォッチゃ
|
||||
Name[kk]=Желі бақылауышы
|
||||
Name[km]=កម្មវិធីមើលបណ្ដាញ
|
||||
Name[kn]=ಜಾಲಬಂಧ ನೋಡುಗ(ವಾಚರ್)
|
||||
Name[ko]=네트워크 모니터
|
||||
Name[lt]=Tinklo stebėtojas
|
||||
Name[lv]=Tīkla novērotājs
|
||||
Name[mai]=नेटवर्क वाचर
|
||||
Name[mk]=Анализатор на мрежи
|
||||
Name[ml]=ശൃംഖല നിരീക്ഷകന്
|
||||
Name[mr]=संजाळ नोंदकर्ता
|
||||
Name[nb]=Nettverksovervåker
|
||||
Name[nds]=Nettwark-Kieker
|
||||
Name[nl]=Netwerkbewaker
|
||||
Name[nn]=Nettverksovervakar
|
||||
Name[pa]=ਨੈੱਟਵਰਕ ਵਾਂਚਰ
|
||||
Name[pl]=Analizator sieci
|
||||
Name[pt]=Vigilante da Rede
|
||||
Name[pt_BR]=Monitor de rede
|
||||
Name[ro]=Supraveghetor rețea
|
||||
Name[ru]=Слежение за сетевыми папками
|
||||
Name[si]=ජාල විශ්ලේෂකය
|
||||
Name[sk]=Sledovanie siete
|
||||
Name[sl]=Opazovalnik omrežja
|
||||
Name[sr]=Надзорник мреже
|
||||
Name[sr@ijekavian]=Надзорник мреже
|
||||
Name[sr@ijekavianlatin]=Nadzornik mreže
|
||||
Name[sr@latin]=Nadzornik mreže
|
||||
Name[sv]=Nätverksövervakare
|
||||
Name[tg]=Нигаҳбони шабакаи Интернет
|
||||
Name[th]=เครื่องมือสอดส่องเครือข่าย
|
||||
Name[tr]=Ağ İzleyici
|
||||
Name[ug]=تور كۆزەتچى
|
||||
Name[uk]=Наглядач мережі
|
||||
Name[vi]=Trình theo dõi mạng
|
||||
Name[wa]=Waiteu d' rantoele
|
||||
Name[x-test]=xxNetwork Watcherxx
|
||||
Name[zh_CN]=网络监视器
|
||||
Name[zh_TW]=網路監控器
|
||||
Comment=Keeps track of the network and updates directory listings of the network:/ protocol
|
||||
Comment[ar]=تعقب لوائح الشبكة وتحديثات الأدلة للشبكة:/
|
||||
Comment[ast]=Rexistra la rede y los anovamientos de llistaos de direutorios del protocolu network:/
|
||||
Comment[bg]=Наблюдение на мрежата и обновяване на съответните списъци на мрежовия протокол
|
||||
Comment[bn]=নেটওয়ার্ক-এর ওপর লক্ষ্য রাখে এবং প্রয়োজনমত network:/ প্রোটোকল-এর ডিরেক্টরি তালিকা আপডেট করে
|
||||
Comment[bs]=Prati mrežu i ažurira ispise fascikli protokola network:/
|
||||
Comment[ca]=Fa un seguiment de la xarxa i actualitza els llistats de directoris del protocol network:/
|
||||
Comment[ca@valencia]=Fa un seguiment de la xarxa i actualitza els llistats de directoris del protocol network:/
|
||||
Comment[cs]=Udržuje přehled o síti a aktualizuje výpisy adresářů protokolu network:/
|
||||
Comment[csb]=Dozérô sécë ë aktualizëje wëskrzënianié katalogów sécë:/ protocol
|
||||
Comment[da]=Holder øje med netværket og opdaterer mappelister for protokollen network:/
|
||||
Comment[de]=Überwacht das Netzwerk und aktualisiert Ordnerauflistungen des Protokolls „network:/“
|
||||
Comment[el]=Καταγραφή του δικτύου και ενημέρωση της λίστας των φακέλων του δικτύου:/πρωτόκολλο
|
||||
Comment[en_GB]=Keeps track of the network and updates directory listings of the network:/ protocol
|
||||
Comment[eo]=Ĝi konservas spuron de la reto kaj ĝisdatigas liston de dosierujoj de la protokolo network:/
|
||||
Comment[es]=Registra la red y las actualizaciones de listados de directorios del protocolo network:/
|
||||
Comment[et]=Hoiab võrgul silma peal ja uuendab protokolli network:/ kataloogide nimekirja
|
||||
Comment[eu]=Sarearen segimendua egiten du eta network:/ protokoloaren direktorio-zerrendak eguneratzen ditu
|
||||
Comment[fi]=Pitää kirjaa verkosta ja päivittää network:/-yhteyskäytännön kansioluettelot
|
||||
Comment[fr]=Conserve des enregistrements du réseau et met à jour les contenus des dossiers pour le protocole « network:/ »
|
||||
Comment[fy]=Hâld de netwurk en fernijings triemtafel listen fan it network:/ protocol yn de gaten
|
||||
Comment[ga]=Coimeádann sé cuntas ar an líonra agus nuashonraíonn comhadlanna den phrótacal network:/
|
||||
Comment[gl]=Mantén un rexistro e actualiza as listas de cartafoles do protocolo network:/
|
||||
Comment[gu]=નેટવર્કની દેખરેખ રાખે છે અને network:/ પ્રોટોકોલની ડિરેક્ટરી યાદીઓ સુધારે છે
|
||||
Comment[he]=משמש למעקב אחר הרשת ולעידכון של רשימת התיקיות בפרוטוקול network:/
|
||||
Comment[hi]=संजाल की जानकारी रखता है और संजाल के निर्देशिका सूचियाँ का अद्यतन करता है:/ protocol
|
||||
Comment[hr]=Pazi na mrežu i ažurira popis direktorija protokola network:/
|
||||
Comment[hu]=Figyeli a hálózat állapotát és frissíti a mappalistákat a network:/ protokollal
|
||||
Comment[ia]=Il mantene tracia del rete e il actualisa listas de directorio de le rete:/protocollo
|
||||
Comment[id]=Pemantauan jaringan dan pemutakhiran pendaftaran direktori dari protokol network:/
|
||||
Comment[is]=Fylgist með netvirkni og uppfærir möppubreytingar með network:/ samskiptareglunni
|
||||
Comment[it]=Tiene traccia della rete e aggiorna la lista delle cartelle del protocollo network:/
|
||||
Comment[ja]=ネットワークのトラックを保持し、network:/ プロトコルのディレクトリリスティングを更新します
|
||||
Comment[kk]=Желіке бақылап отырып network:/ протоколы тізімдерінің қапшығын жаңартып отырады
|
||||
Comment[km]=តាមដានបណ្ដាញ និងធ្វើបច្ចុប្បន្នភាពថត ដោយរាយពិធីការ network:/
|
||||
Comment[ko]=네트워크의 변경 사항을 추적하며 network:/ 프로토콜의 디렉터리 목록을 업데이트합니다
|
||||
Comment[lt]=Seka tinklą ir atnaujina aplankų sąrašą network:/ protokolui
|
||||
Comment[lv]=Seko līdzi tīkam un atjaunina network:/ protokola mapju sarakstus
|
||||
Comment[mk]=Ја следи мрежата и ги ажурира приказите на папки од протоколот network:/
|
||||
Comment[ml]=network:/ പ്രോട്ടോകോളില് ശൃംഖലയുടേയും തട്ടുകളുടെ പട്ടികകളേയും നിരീക്ഷിയ്ക്കുന്നു
|
||||
Comment[mr]=संजाळावर लक्ष ठेउन त्यातील संचयीका यादी अद्ययावत ठेवतो
|
||||
Comment[nb]=Holder øye med nettverket og oppdaterer katalogoppføringer for protokollen network:/
|
||||
Comment[nds]=Beluert dat Nettwark un frischt Orner-Oplisten vun't network:/-Protokoll op
|
||||
Comment[nl]=Bewaakt het netwerk en actualiseert de mappenweergave van het network:/ protocol
|
||||
Comment[nn]=Held auge med nettverket og oppdaterer kataloglistene i network:/-protokollen
|
||||
Comment[pa]=network:/ ਪਰੋਟੋਕਾਲ ਰਾਹੀਂ ਦਿੱਤੀਆਂ ਡਾਇਰੈਕਟਰੀਆਂ ਤੇ ਨੈੱਟਵਰਕ ਬਾਰੀ ਜਾਣਕਾਰੀ ਰੱਖੋ
|
||||
Comment[pl]=Śledzi sieć i uaktualnia zawartości katalogów dla protokołu network:/
|
||||
Comment[pt]=Mantém um registo da rede e actualiza as listagens de pastas no protocolo 'network:/'
|
||||
Comment[pt_BR]=Monitora a rede e atualiza a listagem de diretórios do protocolo network:/
|
||||
Comment[ro]=Duce evidența rețelei și actualizează conținutul dosarelor protocolului network:/
|
||||
Comment[ru]=Поиск служб и обновление содержимого каталогов по протоколу network:/
|
||||
Comment[si]=ජාලය හා ජාලයේ:/ ක්රියාපටිපාටියේ යාවත්කාලීනබහාළුම් ලැයිස්තුගත කිරීමගැන විමසිල්ලෙන් සිටින්න
|
||||
Comment[sk]=Udržuje prehľad o sieti a aktualizuje výpisy adresárov protokolu network:/
|
||||
Comment[sl]=Sledi omrežju in posodablja seznam map za protokol network:/
|
||||
Comment[sr]=Прати мрежу и ажурира исписе фасцикли протокола network:/
|
||||
Comment[sr@ijekavian]=Прати мрежу и ажурира исписе фасцикли протокола network:/
|
||||
Comment[sr@ijekavianlatin]=Prati mrežu i ažurira ispise fascikli protokola network:/
|
||||
Comment[sr@latin]=Prati mrežu i ažurira ispise fascikli protokola network:/
|
||||
Comment[sv]=Håller reda på nätverket och uppdaterar kataloglistningar för protokollet network:/
|
||||
Comment[tg]=Фаъолияти шабакаи Интернетро қайд мекунад ва мазмуни феҳрасти шабакаро навсозӣ мекунад:/ қарордод
|
||||
Comment[th]=คอยติดตามการปรับปรุงของเครือข่าย และการปรับปรุงของไดเรกทอรีผ่านโพรโทคอล network:/
|
||||
Comment[tr]=Ağı ve network:/ protokolündeki dizin güncellemelerini izler
|
||||
Comment[ug]=ئىزلاش تورى ۋە network:/ كېلىشىمى كۆرسەتكەن مۇندەرىجىنىڭ يېڭىلىنىش ئەھۋالى
|
||||
Comment[uk]=Стежить за мережею і оновлює списки каталогів протоколу network:/
|
||||
Comment[vi]=Theo dõi mạng và cập nhật danh sách thư mục trong giao thức network://
|
||||
Comment[wa]=Wåde ene trace des djivêyes des ridants del rantoele et des metaedjes a djoû do protocole network:/
|
||||
Comment[x-test]=xxKeeps track of the network and updates directory listings of the network:/ protocolxx
|
||||
Comment[zh_CN]=跟踪网络及 network:/ 协议所列目录的更新情况
|
||||
Comment[zh_TW]=保持追蹤此網路,並更新 network:/ 協定中的目錄清單
|
|
@ -1,58 +0,0 @@
|
|||
/*
|
||||
This file is part of the network kioslave, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKWATCHER_H
|
||||
#define NETWORKWATCHER_H
|
||||
|
||||
// KDE
|
||||
#include <KDEDModule>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
class Network;
|
||||
class NetDevice;
|
||||
class NetService;
|
||||
typedef QList<NetDevice> NetDeviceList;
|
||||
typedef QList<NetService> NetServiceList;
|
||||
|
||||
|
||||
class NetworkWatcher : public KDEDModule
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
NetworkWatcher( QObject* parent, const QList<QVariant>& parameters );
|
||||
virtual ~NetworkWatcher();
|
||||
|
||||
public:
|
||||
Mollet::NetDevice deviceData( const QString& hostAddress );
|
||||
Mollet::NetService serviceData( const QString& hostAddress, const QString& serviceName, const QString& serviceType );
|
||||
Mollet::NetDeviceList deviceDataList();
|
||||
Mollet::NetServiceList serviceDataList( const QString& hostAddress );
|
||||
|
||||
private:
|
||||
Network* mNetwork;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,14 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.network.KioSlaveNotifier">
|
||||
<method name="watchedDirectories">
|
||||
<arg type="as" direction="out"/>
|
||||
</method>
|
||||
<method name="onDirectoryEntered">
|
||||
<arg name="dir" type="s" direction="in"/>
|
||||
</method>
|
||||
<method name="onDirectoryLeft">
|
||||
<arg name="dir" type="s" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
|
@ -1,11 +0,0 @@
|
|||
<!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 1.0//EN" "http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
|
||||
<node>
|
||||
<interface name="org.kde.network">
|
||||
<method name="service">
|
||||
<arg type="ay" direction="out"/>
|
||||
<arg name="hostName" type="s" direction="in"/>
|
||||
<arg name="serviceName" type="s" direction="in"/>
|
||||
<arg name="type" type="i" direction="in"/>
|
||||
</method>
|
||||
</interface>
|
||||
</node>
|
|
@ -1,62 +0,0 @@
|
|||
project( molletnetwork )
|
||||
|
||||
include_directories(
|
||||
builder
|
||||
)
|
||||
|
||||
set( netsystemdriver_SRCS
|
||||
builder/simpleitemfactory.cpp
|
||||
)
|
||||
|
||||
set( dnssdnetworkbuilder_SRCS
|
||||
builder/dnssd/dnssdnetworkbuilder.cpp
|
||||
)
|
||||
|
||||
set( upnpnetworkbuilder_SRCS
|
||||
builder/upnp/cagibidevice.cpp
|
||||
builder/upnp/cagibidbuscodec.cpp
|
||||
builder/upnp/upnpnetworkbuilder.cpp
|
||||
)
|
||||
|
||||
set( networkbuilder_SRCS
|
||||
builder/abstractnetworkbuilder.cpp
|
||||
builder/abstractnetsystemfactory.cpp
|
||||
)
|
||||
|
||||
set( networkdbus_LIB_SRCS
|
||||
networkdbus.cpp
|
||||
)
|
||||
|
||||
set( molletnetwork_LIB_SRCS
|
||||
${netsystemdriver_SRCS}
|
||||
${upnpnetworkbuilder_SRCS}
|
||||
${dnssdnetworkbuilder_SRCS}
|
||||
${networkbuilder_SRCS}
|
||||
${networkdbus_LIB_SRCS}
|
||||
network_p.cpp
|
||||
network.cpp
|
||||
netdevice_p.cpp
|
||||
netdevice.cpp
|
||||
netservice_p.cpp
|
||||
netservice.cpp
|
||||
)
|
||||
|
||||
|
||||
set( molletnetwork_LINK_LIBS
|
||||
${KDE4_KDECORE_LIBS}
|
||||
${KDE4_KDNSSD_LIBS}
|
||||
${QT_QTNETWORK_LIBRARY}
|
||||
${QT_QTGUI_LIBRARY}
|
||||
)
|
||||
|
||||
add_library( molletnetwork SHARED ${molletnetwork_LIB_SRCS} )
|
||||
target_link_libraries( molletnetwork ${molletnetwork_LINK_LIBS} )
|
||||
|
||||
set_target_properties(molletnetwork PROPERTIES
|
||||
VERSION ${GENERIC_LIB_VERSION}
|
||||
SOVERSION ${GENERIC_LIB_SOVERSION}
|
||||
)
|
||||
|
||||
generate_export_header(molletnetwork)
|
||||
|
||||
install( TARGETS molletnetwork ${INSTALL_TARGETS_DEFAULT_ARGS} )
|
|
@ -1,44 +0,0 @@
|
|||
How does the network get constructed?
|
||||
=============================================
|
||||
|
||||
There are two kind of objects:
|
||||
a) adapters to the service discovery systems
|
||||
b) factories to build network items
|
||||
|
||||
Then there are adapter-specific interface for the factories, so a adapter can
|
||||
handover its system-specific data to the factory.
|
||||
|
||||
The factories understand the data structure the adapters hand over (given they
|
||||
implement its interface) and construct the matching network items, e.g. a
|
||||
NetDevice or a NetService of a certain type.
|
||||
The adapters listen to the discovery systems and on a new item reported by the
|
||||
system ask those factories which implemented their interface if they could
|
||||
turn that into an object in terms of the network library and then tell them
|
||||
to do so if they can.
|
||||
|
||||
Examples:
|
||||
interface: DNSSDNetSystemAble
|
||||
adapter: DNSSDNetworkBuilder
|
||||
factory: SimpleItemFactory (only one so far, anyway)
|
||||
|
||||
Reasoning for this approach:
|
||||
With a plugin system yet to come, one could install a new factory for a
|
||||
service type "coffee/tea filling level", which could understand data from two
|
||||
or three adapters, so you do not need an extra factory for each adapter, but
|
||||
have a central point of competence.
|
||||
|
||||
So now for a new backend you would need to do add these things:
|
||||
a) NEWNetSystemAble
|
||||
b) NEWNetworkBuilder
|
||||
c) have SimpleItemFactory implement NEWNetSystemAble
|
||||
|
||||
SimpleItemFactory is just, as the name should hint, a simple factory, which
|
||||
turns a service description into a plain NetService item, without any
|
||||
additional logic or behaviour. Later on it is planned to have factories which can
|
||||
create complete proxy objects to services on the network. But that needs some
|
||||
more thoughts. Stuff for KDE 4.4, including considering a Solid integration
|
||||
|
||||
The device type detection (heuristics based) is currently pretty bogus and
|
||||
just works for a certain private network, so do not wonder about that part of
|
||||
the code :) It should be really turned of before the 4.3 release and for the time
|
||||
given just have one type of device: a device.
|
|
@ -1,97 +0,0 @@
|
|||
Add backends for
|
||||
* SLP
|
||||
* Jini
|
||||
* UPnP
|
||||
* SMB
|
||||
* manually added devices/services
|
||||
-> means also support for state not-present
|
||||
* scanning?
|
||||
|
||||
list of dns-ds service types: http://www.dns-sd.org/ServiceTypes.html
|
||||
|
||||
See if there could be a xdg database of products with device ontology/categories.
|
||||
|
||||
Add a device guesser which tries to estimate the type of device by the services
|
||||
(or even with a dedicated protocol if there is one?)
|
||||
|
||||
Devices:
|
||||
* Fileserver/-storage
|
||||
* Webserver
|
||||
* Desktop-like Computer (human-interface general purpose)
|
||||
* wearable
|
||||
* MID
|
||||
* Handheld
|
||||
* E-Book reader (is media renderer?)
|
||||
* Laptop
|
||||
* Game server
|
||||
* Server
|
||||
* Router
|
||||
* Internet Gateway Device (IGD)
|
||||
* Mediaserver
|
||||
* Mediarenderer
|
||||
* HVAC
|
||||
* Scanner
|
||||
* WLAN Access point
|
||||
* Digital Security camera
|
||||
* Wearable
|
||||
* Augmented-reality device (headmounted)
|
||||
|
||||
|
||||
Questions:
|
||||
What is a (virtual) device, what is a service?
|
||||
Aren't all servives virtual devices?
|
||||
So present as device or service?
|
||||
|
||||
Some devices use services as interface utility (e.g. a http server for SOAP).
|
||||
Separate human/computer-usable services?
|
||||
Firstlevel service and secondlevel service?
|
||||
|
||||
Physical objects should be represented as physical objects. Perhaps mark with flag.
|
||||
Which of the virtual machines in a server is the physical one if the vm host doesn't show up?
|
||||
|
||||
How to handle unknown devices?
|
||||
Who might want to see them? Developers?
|
||||
Or users, to see it's there but not supported (=without a driver)?
|
||||
There could be a user editable whitelist/blacklist.
|
||||
|
||||
Support should be plugin-based, so 3-party developers can easily try to develop their own drivers.
|
||||
|
||||
|
||||
There need to be servicetype-specific handlers which can create the service proxy object.
|
||||
Should be able to register to different discovery backends (collision handling by priority perhaps).
|
||||
For now simple listing with non-funct system items will do.
|
||||
|
||||
|
||||
{ "_presence._tcp", "presence", "inode/vnd.kde.service.presence", "im-user", false, 0, 0, 0, 0 },
|
||||
// presence http://www.xmpp.org/registrar/linklocal.html
|
||||
// "1st", firstName, "email", emailAddress, "last", lastName, "status", "avail");
|
||||
// TODO: make this first non-simple item, showing addressbook entry
|
||||
|
||||
// KDE
|
||||
{ "_knotes._tcp", "knotes", "inode/vnd.kde.service.knotes", "knotes", false, "http", 0, 0, 0 },
|
||||
|
||||
|
||||
|
||||
QList<NetDevice>& deviceList = mNetworkPrivate->deviceList();
|
||||
static const char* DeviceNamen[] =
|
||||
{
|
||||
"Datensafe.local",
|
||||
"Schleuder.local",
|
||||
"Phlox.local",
|
||||
"buntekuh.local"
|
||||
};
|
||||
for( int i=0; i<4; ++i )
|
||||
{
|
||||
const QString hostName( DeviceNamen[i] );
|
||||
const QString deviceName = hostName.left( hostName.indexOf('.') );
|
||||
NetDevicePrivate* d = new NetDevicePrivate( deviceName, hostName );
|
||||
d->setType( NetDevice::Workstation );
|
||||
|
||||
NetDevice device( d );
|
||||
deviceList.append( device );
|
||||
|
||||
QList<NetDevice> newDevices;
|
||||
newDevices.append( device );
|
||||
mNetworkPrivate->emitDevicesAdded( newDevices );
|
||||
}
|
||||
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "abstractnetsystemfactory.h"
|
|
@ -1,48 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ABSTRACTNETSYSTEMFACTORY_H
|
||||
#define ABSTRACTNETSYSTEMFACTORY_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QObject>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class AbstractNetSystemFactory : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~AbstractNetSystemFactory();
|
||||
|
||||
public: // API to be implemented
|
||||
};
|
||||
|
||||
|
||||
inline AbstractNetSystemFactory::~AbstractNetSystemFactory() {}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,23 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "abstractnetworkbuilder.h"
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef ABSTRACTNETWORKBUILDER_H
|
||||
#define ABSTRACTNETWORKBUILDER_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
class AbstractNetSystemFactory;
|
||||
|
||||
|
||||
class AbstractNetworkBuilder : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
virtual ~AbstractNetworkBuilder();
|
||||
|
||||
public: // API to be implemented
|
||||
// build initial table synch
|
||||
// virtual void init() = 0;
|
||||
// build initial table asynch
|
||||
// virtual void startInit() = 0;
|
||||
|
||||
// TODO: how to handle previously found, but unknown (or now-underpriorized) services? ignore and wait for rescan?
|
||||
virtual void registerNetSystemFactory( AbstractNetSystemFactory* netSystemFactory ) = 0;
|
||||
// temporary solution: have all factories set, then call start
|
||||
virtual void start() = 0;
|
||||
|
||||
|
||||
// drop all knowledge and restart
|
||||
// virtual void rescan()
|
||||
// virtual void startRescan()
|
||||
|
||||
Q_SIGNALS:
|
||||
/** initial structure build */
|
||||
void initDone();
|
||||
};
|
||||
|
||||
|
||||
inline AbstractNetworkBuilder::~AbstractNetworkBuilder() {}
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DNSSDNETSYSTEMABLE_H
|
||||
#define DNSSDNETSYSTEMABLE_H
|
||||
|
||||
// KDE
|
||||
#include <DNSSD/RemoteService>
|
||||
// Qt
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
namespace Mollet {
|
||||
class NetServicePrivate;
|
||||
class NetDevice;
|
||||
}
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class DNSSDNetSystemAble
|
||||
{
|
||||
public:
|
||||
virtual ~DNSSDNetSystemAble();
|
||||
|
||||
public: // API to be implemented
|
||||
virtual bool canCreateNetSystemFromDNSSD( const QString& serviceType ) const = 0;
|
||||
virtual NetServicePrivate* createNetService( const DNSSD::RemoteService::Ptr& service, const NetDevice& device ) const = 0;
|
||||
virtual QString dnssdId( const DNSSD::RemoteService::Ptr& dnssdService ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
inline DNSSDNetSystemAble::~DNSSDNetSystemAble() {}
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_INTERFACE( Mollet::DNSSDNetSystemAble, "org.kde.mollet.dnssdnetsystemable/1.0" )
|
||||
|
||||
#endif
|
|
@ -1,325 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "dnssdnetworkbuilder.h"
|
||||
|
||||
// lib
|
||||
#include "dnssdnetsystemable.h"
|
||||
#include "abstractnetsystemfactory.h"
|
||||
#include "network_p.h"
|
||||
#include "netdevice_p.h"
|
||||
// KDE
|
||||
#include <DNSSD/ServiceTypeBrowser>
|
||||
#include <DNSSD/ServiceBrowser>
|
||||
// Qt
|
||||
#include <QtNetwork/QHostAddress>
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
DNSSDNetworkBuilder::DNSSDNetworkBuilder( NetworkPrivate* networkPrivate )
|
||||
: AbstractNetworkBuilder()
|
||||
, mNetworkPrivate( networkPrivate )
|
||||
, mServiceTypeBrowser( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
void DNSSDNetworkBuilder::registerNetSystemFactory( AbstractNetSystemFactory* netSystemFactory )
|
||||
{
|
||||
DNSSDNetSystemAble* dnssdNetSystemAble = qobject_cast<DNSSDNetSystemAble*>( netSystemFactory );
|
||||
|
||||
if( dnssdNetSystemAble )
|
||||
mNetSystemFactoryList.append( dnssdNetSystemAble );
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::start()
|
||||
{
|
||||
mIsInit = true;
|
||||
mNoOfInitServiceTypes = 0;
|
||||
|
||||
mServiceTypeBrowser = new DNSSD::ServiceTypeBrowser();
|
||||
connect( mServiceTypeBrowser, SIGNAL(serviceTypeAdded(QString)),
|
||||
SLOT(addServiceType(QString)) );
|
||||
connect( mServiceTypeBrowser, SIGNAL(serviceTypeRemoved(QString)),
|
||||
SLOT(removeServiceType(QString)) );
|
||||
connect( mServiceTypeBrowser, SIGNAL(finished()), SLOT(onServiceTypeBrowserFinished()) );
|
||||
// TODO: add a signal network initialized to Network, so is cleared when first usable
|
||||
mServiceTypeBrowser->startBrowse();
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::addServiceType( const QString& serviceType )
|
||||
{
|
||||
kDebug()<<serviceType<<mServiceBrowserTable.contains(serviceType);
|
||||
if( mServiceBrowserTable.contains(serviceType))
|
||||
return;
|
||||
|
||||
// kDebug()<<serviceType;
|
||||
DNSSD::ServiceBrowser* serviceBrowser = new DNSSD::ServiceBrowser( serviceType, true );
|
||||
connect( serviceBrowser, SIGNAL(serviceAdded(DNSSD::RemoteService::Ptr)),
|
||||
SLOT(addService(DNSSD::RemoteService::Ptr)) );
|
||||
connect( serviceBrowser, SIGNAL(serviceRemoved(DNSSD::RemoteService::Ptr)),
|
||||
SLOT(removeService(DNSSD::RemoteService::Ptr)) );
|
||||
|
||||
if( mIsInit )
|
||||
{
|
||||
++mNoOfInitServiceTypes;
|
||||
connect( serviceBrowser, SIGNAL(finished()), SLOT(onServiceBrowserFinished()) );
|
||||
}
|
||||
|
||||
mServiceBrowserTable[serviceType] = serviceBrowser;
|
||||
serviceBrowser->startBrowse();
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::removeServiceType( const QString& serviceType )
|
||||
{
|
||||
kDebug()<<serviceType<<mServiceBrowserTable.contains(serviceType);
|
||||
// for now we keep the service browser (aren't that many) because otherwise
|
||||
// the serviceRemoved calls won't reach us.
|
||||
// we could also go through all the devices and remove the services manually as a fix
|
||||
return;
|
||||
#if 0
|
||||
QHash<QString,DNSSD::ServiceBrowser*>::Iterator it = mServiceBrowserTable.find( serviceType );
|
||||
|
||||
if( it == mServiceBrowserTable.end() )
|
||||
return;
|
||||
|
||||
DNSSD::ServiceBrowser* serviceBrowser = *it;
|
||||
mServiceBrowserTable.erase( it );
|
||||
// TODO: will all servicesRemoved be called before? on test NO!
|
||||
serviceBrowser->deleteLater();
|
||||
#endif
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::addService( DNSSD::RemoteService::Ptr service )
|
||||
{
|
||||
QList<NetDevice>& deviceList = mNetworkPrivate->deviceList();
|
||||
|
||||
QString hostName = service->hostName();
|
||||
// TODO: this blocks. and the ip address should be delivered from DNS-SD with resolve
|
||||
const QHostAddress hostAddress = DNSSD::ServiceBrowser::resolveHostName( hostName );
|
||||
const QString ipAddress = hostAddress.toString();
|
||||
// forget domain name if just ip address
|
||||
if( hostName == ipAddress )
|
||||
hostName.clear();
|
||||
|
||||
// device TODO: only search for if we can create the service?
|
||||
NetDevicePrivate* d = 0;
|
||||
const NetDevice* deviceOfService = 0;
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
const QString deviceHostName = device.hostName();
|
||||
const bool useIpAddress = ( deviceHostName.isEmpty() || hostName.isEmpty() );
|
||||
const bool isSameAddress = useIpAddress ?
|
||||
( device.ipAddress() == ipAddress ) :
|
||||
( deviceHostName == hostName );
|
||||
kDebug()<<"existing device:"<<deviceHostName<<"at"<<device.ipAddress()<<"vs."<<hostName<<"at"<<ipAddress<<":"<<isSameAddress;
|
||||
|
||||
if( isSameAddress )
|
||||
{
|
||||
d = device.dPtr();
|
||||
// workaround: KDNSSD currently (4.7.0) emits two signals per service
|
||||
// just relying on service->serviceName() is fragile, but matches
|
||||
// current approach in removeService(...)
|
||||
QString id;
|
||||
const QString serviceType = service->type();
|
||||
foreach( const DNSSDNetSystemAble* factory, mNetSystemFactoryList )
|
||||
{
|
||||
if( factory->canCreateNetSystemFromDNSSD(serviceType) )
|
||||
{
|
||||
id = factory->dnssdId( service );
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( d->hasService(id) )
|
||||
return;
|
||||
|
||||
deviceOfService = &device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( !d )
|
||||
{
|
||||
const QString deviceName = hostName.left( hostName.indexOf(QLatin1Char('.')) );
|
||||
d = new NetDevicePrivate( deviceName );
|
||||
d->setHostName( hostName );
|
||||
d->setIpAddress( ipAddress );
|
||||
NetDevice device( d );
|
||||
deviceList.append( device );
|
||||
deviceOfService = &deviceList.last();
|
||||
|
||||
QList<NetDevice> newDevices;
|
||||
newDevices.append( device );
|
||||
// TODO: the new service will be announced two times, once with the new device and once alone.
|
||||
// what to do about that? which order? okay? for now just do not attach services before. find usecases.
|
||||
mNetworkPrivate->emitDevicesAdded( newDevices );
|
||||
kDebug()<<"new device:"<<deviceName<<"at"<<hostName<<"by"<<service->type();
|
||||
}
|
||||
else
|
||||
{
|
||||
if( d->hostName().isEmpty() && ! hostName.isEmpty() )
|
||||
d->setHostName( hostName );
|
||||
}
|
||||
|
||||
|
||||
const QString serviceType = service->type();
|
||||
|
||||
NetServicePrivate* netServicePrivate = 0;
|
||||
// do a priority based lookup who can build the object
|
||||
// TODO: priorisation
|
||||
foreach( const DNSSDNetSystemAble* factory, mNetSystemFactoryList )
|
||||
{
|
||||
if( factory->canCreateNetSystemFromDNSSD(serviceType) )
|
||||
{
|
||||
// TODO: here we should rather see if this service already exists
|
||||
netServicePrivate = factory->createNetService( service, *deviceOfService );
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: create dummy service
|
||||
// if( ! netServicePrivate )
|
||||
// netServicePrivate = new UnknownService;
|
||||
|
||||
NetService netService( netServicePrivate );
|
||||
d->addService( netService );
|
||||
|
||||
// try guessing the device type by the services on it
|
||||
// TODO: move into devicefactory
|
||||
NetDevice::Type deviceTypeByService = NetDevice::Unknown;
|
||||
QString deviceName;
|
||||
if( serviceType == QLatin1String("_workstation._tcp") )
|
||||
{
|
||||
deviceTypeByService = NetDevice::Workstation;
|
||||
deviceName = service->serviceName().left( service->serviceName().lastIndexOf(QLatin1Char('[')) ).trimmed();
|
||||
}
|
||||
else if( serviceType == QLatin1String("_net-assistant._udp") )
|
||||
{
|
||||
deviceTypeByService = NetDevice::Workstation;
|
||||
deviceName = service->serviceName();
|
||||
}
|
||||
else if( serviceType == QLatin1String("_airport._tcp") )
|
||||
deviceTypeByService = NetDevice::Router;
|
||||
else if( serviceType == QLatin1String("_ipp._tcp")
|
||||
|| serviceType == QLatin1String("_printer._tcp")
|
||||
|| serviceType == QLatin1String("_pdl-datastream._tcp") )
|
||||
{
|
||||
deviceTypeByService = NetDevice::Printer;
|
||||
deviceName = service->serviceName();
|
||||
}
|
||||
|
||||
if( deviceTypeByService != NetDevice::Unknown )
|
||||
{
|
||||
if( deviceTypeByService > d->type() )
|
||||
{
|
||||
d->setType( deviceTypeByService );
|
||||
if( ! deviceName.isEmpty() )
|
||||
d->setName( deviceName );
|
||||
}
|
||||
}
|
||||
|
||||
QList<NetService> newServices;
|
||||
newServices.append( netService );
|
||||
mNetworkPrivate->emitServicesAdded( newServices );
|
||||
}
|
||||
|
||||
// TODO: each builder should refcount its services, so a shared one does not get removed to early
|
||||
// (might disappear for one sd because of master breakdown)
|
||||
void DNSSDNetworkBuilder::removeService( DNSSD::RemoteService::Ptr service )
|
||||
{
|
||||
QList<NetDevice>& deviceList = mNetworkPrivate->deviceList();
|
||||
|
||||
const QString hostName = service->hostName();
|
||||
|
||||
// device
|
||||
QMutableListIterator<NetDevice> it( deviceList );
|
||||
while( it.hasNext())
|
||||
{
|
||||
const NetDevice& device = it.next();
|
||||
if( device.hostName() == hostName )
|
||||
{
|
||||
// kDebug()<<hostName;
|
||||
QString id;
|
||||
const QString serviceType = service->type();
|
||||
foreach( const DNSSDNetSystemAble* factory, mNetSystemFactoryList )
|
||||
{
|
||||
if( factory->canCreateNetSystemFromDNSSD(serviceType) )
|
||||
{
|
||||
id = factory->dnssdId( service );
|
||||
break;
|
||||
}
|
||||
}
|
||||
NetDevicePrivate* d = device.dPtr();
|
||||
NetService netService = d->removeService( id );
|
||||
if( !netService.isValid() )
|
||||
break;
|
||||
|
||||
QList<NetService> removedServices;
|
||||
removedServices.append( netService );
|
||||
mNetworkPrivate->emitServicesRemoved( removedServices );
|
||||
|
||||
// remove device on last service
|
||||
if( d->serviceList().count() == 0 )
|
||||
{
|
||||
QList<NetDevice> removedDevices;
|
||||
removedDevices.append( device );
|
||||
// remove only after taking copy from reference into removed list
|
||||
it.remove();
|
||||
|
||||
mNetworkPrivate->emitDevicesRemoved( removedDevices );
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::onServiceTypeBrowserFinished()
|
||||
{
|
||||
// kDebug();
|
||||
if( mIsInit )
|
||||
{
|
||||
mIsInit = false;
|
||||
if( mNoOfInitServiceTypes == 0 )
|
||||
emit initDone();
|
||||
}
|
||||
}
|
||||
|
||||
void DNSSDNetworkBuilder::onServiceBrowserFinished()
|
||||
{
|
||||
--mNoOfInitServiceTypes;
|
||||
// kDebug()<<"mIsInit="<<mIsInit<<"mNoOfInitServiceTypes="<<mNoOfInitServiceTypes;
|
||||
// only check for countdown after end of new service types
|
||||
if( !mIsInit && mNoOfInitServiceTypes == 0 )
|
||||
emit initDone();
|
||||
}
|
||||
|
||||
DNSSDNetworkBuilder::~DNSSDNetworkBuilder()
|
||||
{
|
||||
foreach( DNSSD::ServiceBrowser* serviceBrowser, mServiceBrowserTable )
|
||||
delete serviceBrowser;
|
||||
delete mServiceTypeBrowser;
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef DNSSDNETWORKBUILDER_H
|
||||
#define DNSSDNETWORKBUILDER_H
|
||||
|
||||
// lib
|
||||
#include "abstractnetworkbuilder.h"
|
||||
#include "network.h"
|
||||
#include "netdevice.h"
|
||||
// KDE
|
||||
#include <DNSSD/RemoteService>
|
||||
// Qt
|
||||
#include <QtCore/QHash>
|
||||
|
||||
namespace Mollet {
|
||||
class DNSSDNetSystemAble;
|
||||
}
|
||||
|
||||
namespace DNSSD {
|
||||
class ServiceBrowser;
|
||||
class ServiceTypeBrowser;
|
||||
}
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class DNSSDNetworkBuilder : public AbstractNetworkBuilder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit DNSSDNetworkBuilder( NetworkPrivate* networkPrivate );
|
||||
virtual ~DNSSDNetworkBuilder();
|
||||
|
||||
public: // AbstractNetworkBuilder API
|
||||
virtual void registerNetSystemFactory( AbstractNetSystemFactory* netSystemFactory );
|
||||
virtual void start();
|
||||
|
||||
private Q_SLOTS:
|
||||
void addServiceType( const QString& serviceType );
|
||||
void addService( DNSSD::RemoteService::Ptr service );
|
||||
void removeServiceType( const QString& serviceType );
|
||||
void removeService( DNSSD::RemoteService::Ptr service );
|
||||
|
||||
void onServiceTypeBrowserFinished();
|
||||
void onServiceBrowserFinished();
|
||||
|
||||
private: // data
|
||||
NetworkPrivate* mNetworkPrivate;
|
||||
|
||||
DNSSD::ServiceTypeBrowser* mServiceTypeBrowser;
|
||||
QHash<QString,DNSSD::ServiceBrowser*> mServiceBrowserTable;
|
||||
|
||||
QList<DNSSDNetSystemAble*> mNetSystemFactoryList;
|
||||
|
||||
bool mIsInit;
|
||||
int mNoOfInitServiceTypes;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,262 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "simpleitemfactory.h"
|
||||
|
||||
// lib
|
||||
#include "netservice_p.h"
|
||||
// #include "service.h"
|
||||
#include "upnp/cagibidevice.h"
|
||||
|
||||
// Qt
|
||||
#include <QIcon>
|
||||
|
||||
// KDE
|
||||
#include <KUrl>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
struct DNSSDServiceDatum {
|
||||
const char* dnssdTypeName;
|
||||
const char* typeName;
|
||||
const char* fallbackIconName;
|
||||
bool isFilesystem;
|
||||
const char* protocol; // KDE can forward to it
|
||||
const char* pathField;
|
||||
const char* iconField;
|
||||
const char* userField;
|
||||
const char* passwordField;
|
||||
|
||||
void feedUrl( KUrl* url, const DNSSD::RemoteService* remoteService ) const;
|
||||
};
|
||||
|
||||
static const DNSSDServiceDatum DNSSDServiceData[] =
|
||||
{
|
||||
// file services
|
||||
{ "_ftp._tcp", "ftp", "folder-remote", true, "ftp", "path", 0, "u", "p" },
|
||||
{ "_sftp-ssh._tcp", "sftp-ssh", "folder-remote", true, "sftp", 0, 0, "u", "p" },
|
||||
{ "_ftps._tcp", "ftps", "folder-remote", true, "ftps", "path", 0, "u", "p" },
|
||||
{ "_nfs._tcp", "nfs", "folder-remote", true, "nfs", "path", 0, 0, 0 },
|
||||
{ "_afpovertcp._tcp", "afpovertcp", "folder-remote", true, "afp", "path", 0, 0, 0 },
|
||||
{ "_smb._tcp", "smb", "folder-remote", true, "smb", "path", 0, "u", "p" },
|
||||
|
||||
// shell services
|
||||
{ "_ssh._tcp", "ssh", "terminal", false, "ssh", 0, 0, "u", "p" },
|
||||
{ "_telnet._tcp", "telnet", "terminal", false, "telnet", 0, 0, "u", "p" },
|
||||
{ "_rfb._tcp", "rfb", "krfb", false, "vnc", "path", 0, "u", "p" },
|
||||
{ "_rdp._tcp", "rdp", "krfb", false, "rdp", 0, 0, 0, 0 },
|
||||
|
||||
// other standard services
|
||||
{ "_http._tcp", "http", "folder-html", false, "http", "path", 0, "u", "p" },
|
||||
{ "_ntp._udp", "ntp", "xclock", false, 0, 0, 0, 0, 0 },
|
||||
{ "_ldap._tcp", "ldap", "user-group-properties", false, "ldap", 0, 0, 0, 0 },
|
||||
|
||||
// user2user (chat, collaboration)
|
||||
{ "_xmpp-server._tcp", "xmpp-server", "xchat", false, "jabber", 0, 0, 0, 0 },
|
||||
{ "_presence._tcp", "presence", "im-user", false, "presence", 0, 0, 0, 0 },
|
||||
{ "_lobby._tcp", "lobby", "document-edit", false, 0, 0, 0, 0, 0 },
|
||||
{ "_giver._tcp", "giver", "folder-remote", false, 0, 0, 0, 0, 0 },
|
||||
{ "_sip._udp", "sip", "phone", false, 0, 0, 0, 0, 0 },
|
||||
{ "_h323._tcp", "h323", "phone", false, 0, 0, 0, 0, 0 },
|
||||
{ "_skype._tcp", "skype", "phone", false, 0, 0, 0, 0, 0 },
|
||||
|
||||
// printing
|
||||
{ "_ipp._tcp", "ipp", "printer", false, "ipp", "path", 0, "u", "p" },
|
||||
{ "_printer._tcp", "printer", "printer", false, 0, 0, 0, 0, 0 },
|
||||
{ "_pdl-datastream._tcp", "pdl-datastream", "printer", false, 0, 0, 0, 0, 0 },
|
||||
|
||||
// KDE workspace
|
||||
{ "_plasma._tcp", "plasma", "plasma", false, "plasma", "name", "icon", 0, 0 },
|
||||
|
||||
// KDE games
|
||||
{ "_kbattleship._tcp", "kbattleship", "kbattleship", false, "kbattleship", 0, 0, 0, 0 },
|
||||
{ "_lskat._tcp", "lskat", "lskat", false, 0, 0, 0, 0, 0 },
|
||||
{ "_kfourinline._tcp", "kfourinline", "kfourinline", false, 0, 0, 0, 0, 0 },
|
||||
{ "_ksirk._tcp", "ksirk", "ksirk", false, 0, 0, 0, 0, 0 },
|
||||
|
||||
// hardware
|
||||
{ "_pulse-server._tcp","pulse-server","audio-card", false, 0, 0, 0, 0, 0 },
|
||||
{ "_pulse-source._tcp","pulse-source","audio-input-line", false, 0, 0, 0, 0, 0 },
|
||||
{ "_pulse-sink._tcp", "pulse-sink", "speaker", false, 0, 0, 0, 0, 0 },
|
||||
{ "_udisks-ssh._tcp", "udisks-ssh", "drive-harddisk", false, 0, 0, 0, 0, 0 },
|
||||
{ "_libvirt._tcp", "libvirt", "computer", false, 0, 0, 0, 0, 0 },
|
||||
{ "_airmouse._tcp", "airmouse", "input-mouse", false, 0, 0, 0, 0, 0 },
|
||||
|
||||
// database
|
||||
{ "_postgresql._tcp", "postgresql", "server-database", false, 0, 0, 0, 0, 0 },
|
||||
{ "_couchdb_location._tcp", "couchdb_location", "server-database", false, 0, 0, 0, 0, 0 },
|
||||
|
||||
// else
|
||||
{ "_realplayfavs._tcp","realplayfavs","favorites", false, 0, 0, 0, 0, 0 },
|
||||
{ "_acrobatSRV._tcp", "acrobat-server","application-pdf", false, 0, 0, 0, 0, 0 },
|
||||
{ "_adobe-vc._tcp", "adobe-vc", "services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_ggz._tcp", "ggz", "applications-games", false, "ggz", 0, 0, 0, 0 },
|
||||
|
||||
{ "_pgpkey-ldap._tcp", "pgpkey-ldap", "application-pgp-keys", false, 0, 0, 0, 0, 0 },
|
||||
{ "_pgpkey-hkp._tcp", "pgpkey-hkp", "application-pgp-keys", false, 0, 0, 0, 0, 0 },
|
||||
{ "_pgpkey-https._tcp", "pgpkey-https", "application-pgp-keys", true, "https", "path", 0, 0, 0 },
|
||||
|
||||
// Maemo
|
||||
{ "_maemo-inf._tcp", "maemo-inf", "pda", false, 0, 0, 0, 0, 0 },
|
||||
// TODO: _maemo-inf._tcp seems to be not a service, just some about info, use to identify device and hide
|
||||
|
||||
// Apple
|
||||
{ "_airport._tcp", "airport", "network-wireless", false, 0, 0, 0, 0, 0 },
|
||||
{ "_daap._tcp", "daap", "folder-sound", false, 0, 0, 0, 0, 0 },
|
||||
{ "_dacp._tcp", "dacp", "folder-sound", false, 0, 0, 0, 0, 0 },
|
||||
{ "_eppc._tcp", "eppc", "network-connect", false, 0, 0, 0, 0, 0 },
|
||||
{ "_net-assistant._udp", "net-assistant", "services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_odisk._tcp", "odisk", "media-optical", false, 0, 0, 0, 0, 0 },
|
||||
{ "_raop._tcp", "raop", "speaker", false, 0, 0, 0, 0, 0 },
|
||||
{ "_touch-able._tcp", "touch-able", "input-tablet", false, 0, 0, 0, 0, 0 },
|
||||
{ "_workstation._tcp", "workstation", "network-workgroup", false, 0, 0, 0, 0, 0 },
|
||||
{ "_sleep-proxy._udp", "sleep-proxy", "services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_nssocketport._tcp", "nssocketport", "services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_home-sharing._tcp", "home-sharing", "services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_appletv-itunes._tcp","appletv-itunes","services", false, 0, 0, 0, 0, 0 },
|
||||
{ "_appletv-pair._tcp", "appletv-pair", "services", false, 0, 0, 0, 0, 0 }
|
||||
};
|
||||
// result["_ssh._tcp"]= DNSSDNetServiceBuilder(i18n("Remote disk (fish)"), "fish", "service/ftp", QString(), "u", "p");
|
||||
// network-server-database icon
|
||||
// see // SubEthaEdit 2
|
||||
// Defined TXT keys: txtvers=1, name=<Full Name>, userid=<User ID>, version=2
|
||||
|
||||
static const int DNSSDServiceDataSize = sizeof( DNSSDServiceData ) / sizeof( DNSSDServiceData[0] );
|
||||
|
||||
static const DNSSDServiceDatum UnknownServiceDatum = { "", "unknown", "unknown", false, 0, 0, 0, 0, 0 };
|
||||
|
||||
// TODO:
|
||||
// * find out how ws (webservices, _ws._tcp), upnp (_upnp._tcp) are exactly meant to be used
|
||||
// * learn about uddi
|
||||
// * see how the apple specific protocols can be used for devicetype identification (printer, scanner)
|
||||
|
||||
|
||||
void DNSSDServiceDatum::feedUrl( KUrl* url, const DNSSD::RemoteService* remoteService ) const
|
||||
{
|
||||
const QMap<QString,QByteArray> serviceTextData = remoteService->textData();
|
||||
|
||||
url->setProtocol( QString::fromLatin1(protocol) );
|
||||
if( userField )
|
||||
url->setUser( QLatin1String(serviceTextData.value(QLatin1String(userField)).constData()) );
|
||||
if( passwordField )
|
||||
url->setPass( QLatin1String(serviceTextData.value(QLatin1String(passwordField)).constData()) );
|
||||
if( pathField )
|
||||
url->setPath( QLatin1String(serviceTextData.value(QLatin1String(pathField)).constData()) );
|
||||
|
||||
url->setHost( remoteService->hostName() );
|
||||
url->setPort( remoteService->port() );
|
||||
}
|
||||
|
||||
|
||||
SimpleItemFactory::SimpleItemFactory()
|
||||
: AbstractNetSystemFactory()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
bool SimpleItemFactory::canCreateNetSystemFromDNSSD( const QString& serviceType ) const
|
||||
{
|
||||
Q_UNUSED( serviceType )
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SimpleItemFactory::dnssdId( const DNSSD::RemoteService::Ptr& dnssdService ) const
|
||||
{
|
||||
return dnssdService->type() + QLatin1Char('_') + dnssdService->serviceName();
|
||||
}
|
||||
|
||||
NetServicePrivate* SimpleItemFactory::createNetService( const DNSSD::RemoteService::Ptr& dnssdService, const NetDevice& device ) const
|
||||
{
|
||||
NetServicePrivate* result;
|
||||
|
||||
const QString dnssdServiceType = dnssdService->type();
|
||||
|
||||
const DNSSDServiceDatum* serviceDatum = &UnknownServiceDatum;
|
||||
for( int i = 0; i< DNSSDServiceDataSize; ++i )
|
||||
{
|
||||
const DNSSDServiceDatum* datum = &DNSSDServiceData[i];
|
||||
if( dnssdServiceType == QLatin1String(datum->dnssdTypeName) )
|
||||
{
|
||||
serviceDatum = datum;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
KUrl url;
|
||||
if( serviceDatum->protocol )
|
||||
serviceDatum->feedUrl( &url, dnssdService.data() );
|
||||
|
||||
const bool isUnknown = ( serviceDatum == &UnknownServiceDatum );
|
||||
const QString typeName = isUnknown ?
|
||||
dnssdServiceType.mid( 1, dnssdServiceType.lastIndexOf(QLatin1Char('.'))-1 ) :
|
||||
QString::fromLatin1( serviceDatum->typeName );
|
||||
|
||||
QString iconName = QString::fromLatin1(serviceDatum->fallbackIconName);
|
||||
if ( serviceDatum->iconField ) {
|
||||
const QMap<QString,QByteArray> serviceTextData = dnssdService->textData();
|
||||
QString serviceIconName = QString::fromUtf8(serviceTextData[QString::fromLatin1(serviceDatum->iconField)]);
|
||||
if ( QIcon::hasThemeIcon(serviceIconName) ) {
|
||||
iconName = serviceIconName;
|
||||
}
|
||||
}
|
||||
|
||||
result = new NetServicePrivate( dnssdService->serviceName(), iconName,
|
||||
typeName, device, url.url(), SimpleItemFactory::dnssdId(dnssdService) );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool SimpleItemFactory::canCreateNetSystemFromUpnp( const Cagibi::Device& upnpDevice ) const
|
||||
{
|
||||
Q_UNUSED( upnpDevice )
|
||||
return true;
|
||||
}
|
||||
|
||||
QString SimpleItemFactory::upnpId( const Cagibi::Device& upnpDevice ) const
|
||||
{
|
||||
return upnpDevice.udn();
|
||||
}
|
||||
|
||||
// TODO: add KIcon with specialiced KIconLoader (fetches Icons via D-Bus)
|
||||
NetServicePrivate* SimpleItemFactory::createNetService( const Cagibi::Device& upnpDevice, const NetDevice& device ) const
|
||||
{
|
||||
NetServicePrivate* result;
|
||||
|
||||
QString url = upnpDevice.presentationUrl();
|
||||
if( url.isEmpty() )
|
||||
{
|
||||
url = QString::fromLatin1( "upnp://" );
|
||||
url.append( upnpDevice.udn() );
|
||||
}
|
||||
result = new NetServicePrivate( upnpDevice.friendlyName(),
|
||||
QString::fromLatin1("unknown"),
|
||||
QString::fromLatin1("upnp.")+upnpDevice.type(), device, url, SimpleItemFactory::upnpId(upnpDevice) );
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
SimpleItemFactory::~SimpleItemFactory() {}
|
||||
|
||||
}
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef SIMPLEITEMFACTORY_H
|
||||
#define SIMPLEITEMFACTORY_H
|
||||
|
||||
// lib
|
||||
#include <dnssd/dnssdnetsystemable.h>
|
||||
#include <upnp/upnpnetsystemable.h>
|
||||
#include <abstractnetsystemfactory.h>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class SimpleItemFactory : public AbstractNetSystemFactory,
|
||||
public DNSSDNetSystemAble,
|
||||
public UpnpNetSystemAble
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_INTERFACES(
|
||||
Mollet::DNSSDNetSystemAble
|
||||
Mollet::UpnpNetSystemAble
|
||||
)
|
||||
|
||||
public:
|
||||
SimpleItemFactory();
|
||||
virtual ~SimpleItemFactory();
|
||||
|
||||
public: // DNSSDNetSystemAble API
|
||||
virtual bool canCreateNetSystemFromDNSSD( const QString& serviceType ) const;
|
||||
virtual NetServicePrivate* createNetService( const DNSSD::RemoteService::Ptr& service, const NetDevice& device ) const;
|
||||
virtual QString dnssdId( const DNSSD::RemoteService::Ptr& dnssdService ) const;
|
||||
|
||||
public: // UpnpNetSystemAble API
|
||||
virtual bool canCreateNetSystemFromUpnp( const Cagibi::Device& upnpDevice ) const;
|
||||
virtual NetServicePrivate* createNetService( const Cagibi::Device& upnpDevice, const NetDevice& device ) const;
|
||||
virtual QString upnpId( const Cagibi::Device& upnpDevice ) const;
|
||||
|
||||
private:
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,117 +0,0 @@
|
|||
/*
|
||||
This file is part of the KUPnP library, part of the KDE project.
|
||||
|
||||
Copyright 2010-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "cagibidbuscodec.h"
|
||||
|
||||
// network
|
||||
#include "cagibidevice_p.h"
|
||||
// Qt
|
||||
#include <QtDBus/QDBusArgument>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
static const QString type = QLatin1String( "deviceType" );
|
||||
static const QString friendlyName = QLatin1String( "friendlyName" );
|
||||
static const QString manufacturerName = QLatin1String( "manufacturer" );
|
||||
static const QString modelDescription = QLatin1String( "modelDescription" );
|
||||
static const QString modelName = QLatin1String( "modelName" );
|
||||
static const QString modelNumber = QLatin1String( "modelNumber" );
|
||||
static const QString serialNumber = QLatin1String( "serialNumber" );
|
||||
static const QString udn = QLatin1String( "UDN" );
|
||||
static const QString presentationUrl = QLatin1String( "presentationURL" );
|
||||
static const QString ipAddress = QLatin1String( "ipAddress" );
|
||||
static const QString portNumber = QLatin1String( "ipPortNumber" );
|
||||
static const QString parentDeviceUdn = QLatin1String( "parentDeviceUDN" );
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
QDBusArgument& operator<<( QDBusArgument& argument, const Cagibi::Device& device )
|
||||
{
|
||||
Q_UNUSED( device )
|
||||
// not used in code at the moment, so do not stream anything
|
||||
// QtDBus marshaller still uses it to calculate the D-Bus argument signature
|
||||
argument.beginMap( QVariant::String, QVariant::String );
|
||||
argument.endMap();
|
||||
|
||||
return argument;
|
||||
}
|
||||
|
||||
const QDBusArgument& operator>>( const QDBusArgument& argument,
|
||||
Cagibi::Device& device )
|
||||
{
|
||||
Cagibi::DevicePrivate* const devicePrivate = device.d.data();
|
||||
|
||||
argument.beginMap();
|
||||
|
||||
QString key;
|
||||
QString value;
|
||||
while( ! argument.atEnd() )
|
||||
{
|
||||
argument.beginMapEntry();
|
||||
argument >> key;
|
||||
|
||||
if( key == type )
|
||||
{
|
||||
QString type;
|
||||
argument >> type;
|
||||
const QStringList typeParts = type.split( QLatin1Char(':') );
|
||||
qDebug()<<type;
|
||||
if( typeParts.size() >=5 )
|
||||
devicePrivate->mType = typeParts[3]+typeParts[4];
|
||||
}
|
||||
else if( key == friendlyName )
|
||||
argument >> devicePrivate->mFriendlyName;
|
||||
else if( key == manufacturerName )
|
||||
argument >> devicePrivate->mManufacturerName;
|
||||
// const QString& manufacturerUrl() const;
|
||||
else if( key == modelDescription )
|
||||
argument >> devicePrivate->mModelDescription;
|
||||
else if( key == modelName )
|
||||
argument >> devicePrivate->mModelName;
|
||||
else if( key == modelNumber )
|
||||
argument >> devicePrivate->mModelNumber;
|
||||
else if( key == serialNumber )
|
||||
argument >> devicePrivate->mSerialNumber;
|
||||
else if( key == udn )
|
||||
argument >> devicePrivate->mUdn;
|
||||
// const QString upc() const;
|
||||
else if( key == presentationUrl )
|
||||
argument >> devicePrivate->mPresentationUrl;
|
||||
else if( key == ipAddress )
|
||||
argument >> devicePrivate->mIpAddress;
|
||||
else if( key == portNumber )
|
||||
argument >> devicePrivate->mIpPortNumber;
|
||||
else if( key == parentDeviceUdn )
|
||||
argument >> devicePrivate->mParentDeviceUdn;
|
||||
// const QList<Icon>& icons() const;
|
||||
// const QList<Service>& services() const;
|
||||
// const QList<Device>& devices() const;
|
||||
// unknown key
|
||||
else
|
||||
argument >> value;
|
||||
argument.endMapEntry();
|
||||
}
|
||||
|
||||
argument.endMap();
|
||||
|
||||
return argument;
|
||||
}
|
||||
QT_END_NAMESPACE
|
|
@ -1,42 +0,0 @@
|
|||
/*
|
||||
This file is part of the KUPnP library, part of the KDE project.
|
||||
|
||||
Copyright 2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CAGIBIDBUSCODEC_H
|
||||
#define CAGIBIDBUSCODEC_H
|
||||
|
||||
// lib
|
||||
#include "cagibidevice.h"
|
||||
// Qt
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtCore/QVector>
|
||||
#include <QDBusArgument>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
QDBusArgument& operator<<( QDBusArgument& argument,
|
||||
const Cagibi::Device& device );
|
||||
const QDBusArgument& operator>>( const QDBusArgument& argument,
|
||||
Cagibi::Device& device );
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE( Cagibi::Device )
|
||||
|
||||
#endif
|
|
@ -1,70 +0,0 @@
|
|||
/*
|
||||
This file is part of the KUPnP library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "cagibidevice.h"
|
||||
#include "cagibidevice_p.h"
|
||||
|
||||
|
||||
namespace Cagibi
|
||||
{
|
||||
|
||||
Device::Device()
|
||||
: d( new DevicePrivate() )
|
||||
{
|
||||
}
|
||||
|
||||
Device::Device( DevicePrivate* _d )
|
||||
: d( _d )
|
||||
{
|
||||
}
|
||||
|
||||
Device::Device( const Device& other )
|
||||
: d( other.d )
|
||||
{
|
||||
}
|
||||
|
||||
const QString& Device::type() const { return d->type(); }
|
||||
const QString& Device::friendlyName() const { return d->friendlyName(); }
|
||||
const QString& Device::manufacturerName() const { return d->manufacturerName(); }
|
||||
const QString& Device::modelDescription() const { return d->modelDescription(); }
|
||||
const QString& Device::modelName() const { return d->modelName(); }
|
||||
const QString& Device::modelNumber() const { return d->modelNumber(); }
|
||||
const QString& Device::serialNumber() const { return d->serialNumber(); }
|
||||
const QString& Device::udn() const { return d->udn(); }
|
||||
const QString& Device::presentationUrl() const { return d->presentationUrl(); }
|
||||
const QString& Device::ipAddress() const { return d->ipAddress(); }
|
||||
int Device::ipPortNumber() const { return d->ipPortNumber(); }
|
||||
|
||||
bool Device::hasParentDevice() const { return d->hasParentDevice(); }
|
||||
const QString& Device::parentDeviceUdn() const { return d->parentDeviceUdn(); }
|
||||
|
||||
Device& Device::operator=( const Device& other )
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
Device::~Device()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,90 +0,0 @@
|
|||
/*
|
||||
This file is part of the KUPnP library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CAGIBIDEVICE_H
|
||||
#define CAGIBIDEVICE_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/qsharedpointer.h>
|
||||
#include <QString>
|
||||
#include <QDBusArgument>
|
||||
|
||||
namespace Cagibi { class Device; }
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern QDBusArgument& operator<<( QDBusArgument& argument,
|
||||
const Cagibi::Device& device );
|
||||
extern const QDBusArgument& operator>>( const QDBusArgument& argument,
|
||||
Cagibi::Device& device );
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Cagibi
|
||||
{
|
||||
class DevicePrivate;
|
||||
|
||||
class Device
|
||||
{
|
||||
#ifndef QT_NAMESPACE
|
||||
friend QDBusArgument& ::operator<<( QDBusArgument& argument, const Cagibi::Device& device );
|
||||
friend const QDBusArgument& ::operator>>( const QDBusArgument& argument, Cagibi::Device& device );
|
||||
#else
|
||||
friend QDBusArgument& ::QT_NAMESPACE::operator<<( QDBusArgument& argument, const Cagibi::Device& device );
|
||||
friend const QDBusArgument& ::QT_NAMESPACE::operator>>( const QDBusArgument& argument, Cagibi::Device& device );
|
||||
#endif
|
||||
|
||||
protected:
|
||||
explicit Device( DevicePrivate* _d );
|
||||
|
||||
public:
|
||||
Device();
|
||||
Device( const Device& other );
|
||||
|
||||
~Device();
|
||||
|
||||
public:
|
||||
Device& operator=( const Device& other );
|
||||
|
||||
public:
|
||||
const QString& type() const;
|
||||
const QString& friendlyName() const;
|
||||
const QString& manufacturerName() const;
|
||||
// QString manufacturerUrl() const;
|
||||
const QString& modelDescription() const;
|
||||
const QString& modelName() const;
|
||||
const QString& modelNumber() const;
|
||||
const QString& serialNumber() const;
|
||||
const QString& udn() const;
|
||||
// QString upc() const;
|
||||
const QString& presentationUrl() const;
|
||||
const QString& ipAddress() const;
|
||||
int ipPortNumber() const;
|
||||
|
||||
bool hasParentDevice() const;
|
||||
const QString& parentDeviceUdn() const;
|
||||
|
||||
protected:
|
||||
QExplicitlySharedDataPointer<DevicePrivate> d;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,104 +0,0 @@
|
|||
/*
|
||||
This file is part of the KUPnP library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2010 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef CAGIBIDEVICE_P_H
|
||||
#define CAGIBIDEVICE_P_H
|
||||
|
||||
// lib
|
||||
#include "cagibidevice.h"
|
||||
// Qt
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QSharedData>
|
||||
|
||||
|
||||
namespace Cagibi
|
||||
{
|
||||
|
||||
class DevicePrivate : public QSharedData
|
||||
{
|
||||
#ifndef QT_NAMESPACE
|
||||
friend const QDBusArgument& ::operator>>( const QDBusArgument& argument, Cagibi::Device& device );
|
||||
#else
|
||||
friend const QDBusArgument& ::QT_NAMESPACE::operator>>( const QDBusArgument& argument, Cagibi::Device& device );
|
||||
#endif
|
||||
|
||||
public:
|
||||
DevicePrivate();
|
||||
|
||||
public:
|
||||
const QString& type() const;
|
||||
const QString& friendlyName() const;
|
||||
const QString& manufacturerName() const;
|
||||
// const QString& manufacturerUrl() const;
|
||||
const QString& modelDescription() const;
|
||||
const QString& modelName() const;
|
||||
const QString& modelNumber() const;
|
||||
const QString& serialNumber() const;
|
||||
const QString& udn() const;
|
||||
// const QString upc() const;
|
||||
const QString& presentationUrl() const;
|
||||
const QString& ipAddress() const;
|
||||
int ipPortNumber() const;
|
||||
|
||||
bool hasParentDevice() const;
|
||||
const QString& parentDeviceUdn() const;
|
||||
|
||||
protected:
|
||||
QString mType;
|
||||
/// short user-friendly title
|
||||
QString mFriendlyName;
|
||||
QString mManufacturerName;
|
||||
// QString mManufacturerUrl;
|
||||
/// long user-friendly title
|
||||
QString mModelDescription;
|
||||
QString mModelName;
|
||||
QString mModelNumber;
|
||||
QString mSerialNumber;
|
||||
QString mUdn;
|
||||
// QString mUpc; Universal Product Code;
|
||||
QString mPresentationUrl;
|
||||
|
||||
QString mIpAddress;
|
||||
int mIpPortNumber;
|
||||
|
||||
QString mParentDeviceUdn;
|
||||
};
|
||||
|
||||
|
||||
inline DevicePrivate::DevicePrivate() {}
|
||||
inline const QString& DevicePrivate::type() const { return mType; }
|
||||
inline const QString& DevicePrivate::friendlyName() const { return mFriendlyName; }
|
||||
inline const QString& DevicePrivate::manufacturerName() const { return mManufacturerName; }
|
||||
inline const QString& DevicePrivate::modelDescription() const { return mModelDescription; }
|
||||
inline const QString& DevicePrivate::modelName() const { return mModelName; }
|
||||
inline const QString& DevicePrivate::modelNumber() const { return mModelNumber; }
|
||||
inline const QString& DevicePrivate::serialNumber() const { return mSerialNumber; }
|
||||
inline const QString& DevicePrivate::udn() const { return mUdn; }
|
||||
inline const QString& DevicePrivate::presentationUrl() const { return mPresentationUrl; }
|
||||
inline const QString& DevicePrivate::ipAddress() const { return mIpAddress; }
|
||||
inline int DevicePrivate::ipPortNumber() const { return mIpPortNumber; }
|
||||
inline bool DevicePrivate::hasParentDevice() const { return (! mParentDeviceUdn.isEmpty() ); }
|
||||
inline const QString& DevicePrivate::parentDeviceUdn() const { return mParentDeviceUdn; }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,59 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UPNPNETSYSTEMABLE_H
|
||||
#define UPNPNETSYSTEMABLE_H
|
||||
|
||||
// Qt
|
||||
#include <QtCore/qplugin.h>
|
||||
|
||||
namespace Cagibi {
|
||||
class Device;
|
||||
}
|
||||
#include <QString>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
class NetServicePrivate;
|
||||
class NetDevice;
|
||||
|
||||
|
||||
class UpnpNetSystemAble
|
||||
{
|
||||
public:
|
||||
virtual ~UpnpNetSystemAble();
|
||||
|
||||
public: // API to be implemented
|
||||
virtual bool canCreateNetSystemFromUpnp( const Cagibi::Device& upnpDevice ) const = 0;
|
||||
virtual NetServicePrivate* createNetService( const Cagibi::Device& upnpDevice, const NetDevice& device ) const = 0;
|
||||
virtual QString upnpId( const Cagibi::Device& upnpDevice ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
inline UpnpNetSystemAble::~UpnpNetSystemAble() {}
|
||||
|
||||
}
|
||||
|
||||
Q_DECLARE_INTERFACE( Mollet::UpnpNetSystemAble, "org.kde.mollet.upnpnetsystemable/1.0" )
|
||||
|
||||
#endif
|
|
@ -1,356 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009-2011 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "upnpnetworkbuilder.h"
|
||||
|
||||
// lib
|
||||
#include "upnpnetsystemable.h"
|
||||
#include "abstractnetsystemfactory.h"
|
||||
#include "network_p.h"
|
||||
#include "netdevice_p.h"
|
||||
#include "netservice_p.h"
|
||||
#include "cagibidevice.h"
|
||||
#include "cagibidbuscodec.h"
|
||||
// Qt
|
||||
#include <QtDBus/QDBusMetaType>
|
||||
#include <QtDBus/QDBusReply>
|
||||
#include <QtDBus/QDBusConnection>
|
||||
#include <QtDBus/QDBusInterface>
|
||||
#include <QtDBus/qdbuspendingcall.h>
|
||||
#include <QtDBus/QDBusServiceWatcher>
|
||||
#include <QtCore/QStringList>
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
static const char cagibiServiceName[] = "org.kde.Cagibi";
|
||||
static const char cagibiDeviceListObjectPath[] = "/org/kde/Cagibi/DeviceList";
|
||||
static const char cagibiDeviceListInterface[] = "org.kde.Cagibi.DeviceList";
|
||||
|
||||
UpnpNetworkBuilder::UpnpNetworkBuilder( NetworkPrivate* networkPrivate )
|
||||
: AbstractNetworkBuilder()
|
||||
, mNetworkPrivate( networkPrivate )
|
||||
, mCagibiDeviceListDBusProxy( 0 )
|
||||
{
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::registerNetSystemFactory( AbstractNetSystemFactory* netSystemFactory )
|
||||
{
|
||||
UpnpNetSystemAble* upnpNetSystemAble = qobject_cast<UpnpNetSystemAble*>( netSystemFactory );
|
||||
|
||||
if( upnpNetSystemAble )
|
||||
mNetSystemFactoryList.append( upnpNetSystemAble );
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::start()
|
||||
{
|
||||
QMetaObject::invokeMethod( this, "startBrowse", Qt::QueuedConnection );
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::startBrowse()
|
||||
{
|
||||
qDBusRegisterMetaType<DeviceTypeMap>();
|
||||
qDBusRegisterMetaType<Cagibi::Device>();
|
||||
|
||||
QDBusConnection dbusConnection = QDBusConnection::systemBus();
|
||||
|
||||
const QString serviceName = QLatin1String( cagibiServiceName );
|
||||
const QString deviceListObjectPath = QLatin1String( cagibiDeviceListObjectPath );
|
||||
const QString deviceListInterface = QLatin1String( cagibiDeviceListInterface );
|
||||
|
||||
// install service watcher
|
||||
QDBusServiceWatcher* cagibiServiceWatcher =
|
||||
new QDBusServiceWatcher( serviceName,
|
||||
dbusConnection,
|
||||
QDBusServiceWatcher::WatchForOwnerChange,
|
||||
this );
|
||||
connect( cagibiServiceWatcher, SIGNAL(serviceOwnerChanged(QString,QString,QString)),
|
||||
SLOT(onCagibiServiceOwnerChanged(QString,QString,QString)) );
|
||||
|
||||
// create devicelist proxy
|
||||
mCagibiDeviceListDBusProxy =
|
||||
new QDBusInterface( serviceName,
|
||||
deviceListObjectPath,
|
||||
deviceListInterface,
|
||||
dbusConnection, this );
|
||||
connect( mCagibiDeviceListDBusProxy, SIGNAL(devicesAdded(DeviceTypeMap)),
|
||||
SLOT(onDevicesAdded(DeviceTypeMap)) );
|
||||
connect( mCagibiDeviceListDBusProxy, SIGNAL(devicesRemoved(DeviceTypeMap)),
|
||||
SLOT(onDevicesRemoved(DeviceTypeMap)) );
|
||||
|
||||
// query current devicelist
|
||||
queryCurrentDevices();
|
||||
|
||||
emit initDone();
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::queryCurrentDevices()
|
||||
{
|
||||
// query current devicelist
|
||||
QDBusPendingCall allDevicesCall =
|
||||
mCagibiDeviceListDBusProxy->asyncCall( QLatin1String("allDevices") );
|
||||
|
||||
QDBusPendingCallWatcher* allDevicesCallWatcher =
|
||||
new QDBusPendingCallWatcher( allDevicesCall, this );
|
||||
connect( allDevicesCallWatcher, SIGNAL(finished(QDBusPendingCallWatcher*)),
|
||||
SLOT(onAllDevicesCallFinished(QDBusPendingCallWatcher*)) );
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::onAllDevicesCallFinished( QDBusPendingCallWatcher* allDevicesCallWatcher )
|
||||
{
|
||||
QDBusReply<DeviceTypeMap> reply = *allDevicesCallWatcher;
|
||||
|
||||
if( reply.isValid() )
|
||||
{
|
||||
kDebug() << "Connected to Cagibi, listing of UPnP devices/services started.";
|
||||
const DeviceTypeMap deviceTypeMap = reply;
|
||||
onDevicesAdded( deviceTypeMap );
|
||||
}
|
||||
else
|
||||
{
|
||||
kDebug() << "Could not connect to Cagibi, no listing of UPnP devices/services.";
|
||||
kDebug() << "Error: " << reply.error().name();
|
||||
}
|
||||
|
||||
delete allDevicesCallWatcher;
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::addUPnPDevices( const QList<Cagibi::Device>& upnpDevices )
|
||||
{
|
||||
QList<NetDevice> addedDevices;
|
||||
QList<NetService> addedServices;
|
||||
|
||||
QList<NetDevice>& deviceList = mNetworkPrivate->deviceList();
|
||||
foreach( const Cagibi::Device& upnpDevice, upnpDevices )
|
||||
{
|
||||
if( upnpDevice.hasParentDevice() )
|
||||
continue;
|
||||
|
||||
const QString ipAddress = upnpDevice.ipAddress();
|
||||
|
||||
NetDevicePrivate* d = 0;
|
||||
const NetDevice* deviceOfService = 0;
|
||||
foreach( const NetDevice& device, deviceList )
|
||||
{
|
||||
const bool isSameAddress = ( device.ipAddress() == ipAddress );
|
||||
kDebug()<<"existing device:"<<device.hostName()<<"at"<<device.ipAddress()<<"vs."<<ipAddress<<":"<<isSameAddress;
|
||||
// TODO: lookup hostname and try to use that
|
||||
if( isSameAddress )
|
||||
{
|
||||
d = device.dPtr();
|
||||
deviceOfService = &device;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if( ! d )
|
||||
{
|
||||
const QString displayName = upnpDevice.friendlyName();
|
||||
|
||||
const QString deviceName = displayName;
|
||||
d = new NetDevicePrivate( deviceName );
|
||||
d->setIpAddress( ipAddress );
|
||||
|
||||
NetDevice device( d );
|
||||
addedDevices.append( device );
|
||||
deviceList.append( device );
|
||||
deviceOfService = &deviceList.last();
|
||||
kDebug()<<"new device:"<<deviceName<<"at"<<ipAddress;
|
||||
}
|
||||
|
||||
NetServicePrivate* netServicePrivate = 0;
|
||||
// do a priority based lookup who can build the object
|
||||
// TODO: priorisation
|
||||
foreach( const UpnpNetSystemAble* factory, mNetSystemFactoryList )
|
||||
{
|
||||
if( factory->canCreateNetSystemFromUpnp(upnpDevice) )
|
||||
{
|
||||
// TODO: here we should rather see if this service already exists
|
||||
netServicePrivate = factory->createNetService( upnpDevice, *deviceOfService );
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
NetService netService( netServicePrivate );
|
||||
d->addService( netService );
|
||||
|
||||
addedServices.append( netService );
|
||||
kDebug()<<"new service:"<<netService.name()<<netService.url();
|
||||
|
||||
// try guessing the device type by the services on it
|
||||
// TODO: move into devicefactory
|
||||
const QString serviceType = upnpDevice.type();
|
||||
NetDevice::Type deviceTypeByService = NetDevice::Unknown;
|
||||
QString deviceName;
|
||||
if( serviceType == QLatin1String("InternetGatewayDevice1") )
|
||||
deviceTypeByService = NetDevice::Router;
|
||||
else if( serviceType == QLatin1String("PrinterBasic1")
|
||||
|| serviceType == QLatin1String("PrinterEnhanced1") )
|
||||
deviceTypeByService = NetDevice::Printer;
|
||||
else if( serviceType == QLatin1String("Scanner1") )
|
||||
deviceTypeByService = NetDevice::Scanner;
|
||||
|
||||
if( deviceTypeByService != NetDevice::Unknown )
|
||||
{
|
||||
if( deviceTypeByService > d->type() )
|
||||
{
|
||||
d->setType( deviceTypeByService );
|
||||
if( ! deviceName.isEmpty() )
|
||||
d->setName( deviceName );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if( ! addedDevices.isEmpty() )
|
||||
mNetworkPrivate->emitDevicesAdded( addedDevices );
|
||||
if( ! addedServices.isEmpty() )
|
||||
mNetworkPrivate->emitServicesAdded( addedServices );
|
||||
}
|
||||
|
||||
|
||||
void UpnpNetworkBuilder::removeUPnPDevices( const QList<Cagibi::Device>& upnpDevices )
|
||||
{
|
||||
QList<NetDevice> removedDevices;
|
||||
QList<NetService> removedServices;
|
||||
|
||||
QList<NetDevice>& deviceList = mNetworkPrivate->deviceList();
|
||||
foreach( const Cagibi::Device& upnpDevice, upnpDevices )
|
||||
{
|
||||
const QString ipAddress = upnpDevice.ipAddress();
|
||||
|
||||
QMutableListIterator<NetDevice> it( deviceList );
|
||||
while( it.hasNext())
|
||||
{
|
||||
const NetDevice& device = it.next();
|
||||
if( device.ipAddress() == ipAddress )
|
||||
{
|
||||
QString id;
|
||||
foreach( const UpnpNetSystemAble* factory, mNetSystemFactoryList )
|
||||
{
|
||||
if( factory->canCreateNetSystemFromUpnp(upnpDevice) )
|
||||
{
|
||||
id = factory->upnpId( upnpDevice );
|
||||
break;
|
||||
}
|
||||
}
|
||||
NetDevicePrivate* d = device.dPtr();
|
||||
NetService netService = d->removeService( id );
|
||||
if( ! netService.isValid() )
|
||||
break;
|
||||
|
||||
removedServices.append( netService );
|
||||
|
||||
// remove device on last service
|
||||
if( d->serviceList().count() == 0 )
|
||||
{
|
||||
removedDevices.append( device );
|
||||
// remove only after taking copy from reference into removed list
|
||||
it.remove();
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if( ! removedServices.isEmpty() )
|
||||
mNetworkPrivate->emitServicesRemoved( removedServices );
|
||||
if( ! removedDevices.isEmpty() )
|
||||
mNetworkPrivate->emitDevicesRemoved( removedDevices );
|
||||
}
|
||||
|
||||
|
||||
void UpnpNetworkBuilder::onDevicesAdded( const DeviceTypeMap& deviceTypeMap )
|
||||
{
|
||||
DeviceTypeMap::ConstIterator it = deviceTypeMap.constBegin();
|
||||
DeviceTypeMap::ConstIterator end = deviceTypeMap.constEnd();
|
||||
for( ; it != end; ++it )
|
||||
{
|
||||
const QString udn = it.key();
|
||||
QList<QVariant> args;
|
||||
args << udn;
|
||||
mCagibiDeviceListDBusProxy->callWithCallback(
|
||||
QLatin1String("deviceDetails"), args,
|
||||
this, SLOT(onAddedDeviceDetails(Cagibi::Device)), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::onDevicesRemoved( const DeviceTypeMap& deviceTypeMap )
|
||||
{
|
||||
QList<Cagibi::Device> upnpDevices;
|
||||
|
||||
DeviceTypeMap::ConstIterator it = deviceTypeMap.constBegin();
|
||||
DeviceTypeMap::ConstIterator end = deviceTypeMap.constEnd();
|
||||
for( ; it != end; ++it )
|
||||
{
|
||||
QHash<QString,Cagibi::Device>::Iterator adIt =
|
||||
mActiveDevices.find( it.key() );
|
||||
if( adIt != mActiveDevices.end() )
|
||||
{
|
||||
kDebug()<<"removing UPnP device" << adIt.value().friendlyName();
|
||||
upnpDevices.append( adIt.value() );
|
||||
mActiveDevices.erase( adIt );
|
||||
}
|
||||
}
|
||||
|
||||
removeUPnPDevices( upnpDevices );
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::onAddedDeviceDetails( const Cagibi::Device& device )
|
||||
{
|
||||
// currently only root devices are shown
|
||||
if( device.hasParentDevice() )
|
||||
return;
|
||||
|
||||
mActiveDevices.insert( device.udn(), device );
|
||||
|
||||
QList<Cagibi::Device> devices;
|
||||
devices.append( device );
|
||||
addUPnPDevices( devices );
|
||||
}
|
||||
|
||||
void UpnpNetworkBuilder::onCagibiServiceOwnerChanged( const QString& serviceName,
|
||||
const QString& oldOwner,
|
||||
const QString& newOwner )
|
||||
{
|
||||
Q_UNUSED(serviceName);
|
||||
Q_UNUSED(newOwner);
|
||||
|
||||
// old service disappeared?
|
||||
if( ! oldOwner.isEmpty() )
|
||||
{
|
||||
kDebug()<<"Cagibi disappeared, removing all UPnP devices";
|
||||
|
||||
// remove all registered UPnP devices
|
||||
QList<Cagibi::Device> upnpDevices = mActiveDevices.values();
|
||||
mActiveDevices.clear();
|
||||
|
||||
removeUPnPDevices( upnpDevices );
|
||||
}
|
||||
|
||||
if( ! newOwner.isEmpty() )
|
||||
queryCurrentDevices();
|
||||
}
|
||||
|
||||
UpnpNetworkBuilder::~UpnpNetworkBuilder()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,91 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef UPNPNETWORKBUILDER_H
|
||||
#define UPNPNETWORKBUILDER_H
|
||||
|
||||
// lib
|
||||
#include <abstractnetworkbuilder.h>
|
||||
#include <network.h>
|
||||
#include <netdevice.h>
|
||||
// Qt
|
||||
#include <QtCore/QMetaType>
|
||||
#include <QtCore/QHash>
|
||||
|
||||
namespace Cagibi { class Device; }
|
||||
|
||||
#include <QDBusInterface>
|
||||
#include <QDBusPendingCallWatcher>
|
||||
|
||||
typedef QHash<QString,QString> DeviceTypeMap;
|
||||
Q_DECLARE_METATYPE( DeviceTypeMap )
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
class UpnpNetSystemAble;
|
||||
|
||||
|
||||
class UpnpNetworkBuilder : public AbstractNetworkBuilder
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit UpnpNetworkBuilder( NetworkPrivate* networkPrivate );
|
||||
virtual ~UpnpNetworkBuilder();
|
||||
|
||||
public: // AbstractNetworkBuilder API
|
||||
virtual void registerNetSystemFactory( AbstractNetSystemFactory* netSystemFactory );
|
||||
virtual void start();
|
||||
//TODO: void stop(); ? why needed, what to do?
|
||||
|
||||
protected:
|
||||
void addUPnPDevices( const QList<Cagibi::Device>& devices );
|
||||
void removeUPnPDevices( const QList<Cagibi::Device>& devices );
|
||||
|
||||
private Q_SLOTS:
|
||||
void startBrowse();
|
||||
|
||||
void onDevicesAdded( const DeviceTypeMap& deviceTypeMap );
|
||||
void onDevicesRemoved( const DeviceTypeMap& deviceTypeMap );
|
||||
void onAddedDeviceDetails( const Cagibi::Device& device );
|
||||
void onCagibiServiceOwnerChanged( const QString& serviceName,
|
||||
const QString& oldOwner, const QString& newOwner );
|
||||
|
||||
void onAllDevicesCallFinished( QDBusPendingCallWatcher* allDevicesCallWatcher );
|
||||
|
||||
private:
|
||||
void queryCurrentDevices();
|
||||
|
||||
private: // data
|
||||
NetworkPrivate* mNetworkPrivate;
|
||||
|
||||
QList<UpnpNetSystemAble*> mNetSystemFactoryList;
|
||||
|
||||
QHash<QString,Cagibi::Device> mActiveDevices;
|
||||
|
||||
QDBusInterface* mCagibiDeviceListDBusProxy;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,83 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "netdevice.h"
|
||||
#include "netdevice_p.h"
|
||||
|
||||
// KDE
|
||||
#include <KGlobal>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
K_GLOBAL_STATIC_WITH_ARGS(KSharedPtr< NetDevicePrivate >, dummyNetDevicePrivate, ( new NetDevicePrivate(QString()) ))
|
||||
|
||||
|
||||
QString NetDevice::iconName( Type type )
|
||||
{
|
||||
static const char* const IconName[] =
|
||||
{
|
||||
/*"unknown"*/"network-server", "scanner", "printer", "network-server-database", "network-server", "computer"
|
||||
};
|
||||
|
||||
return QLatin1String(IconName[type]);
|
||||
}
|
||||
|
||||
NetDevice::NetDevice()
|
||||
: d( *dummyNetDevicePrivate )
|
||||
{
|
||||
}
|
||||
|
||||
NetDevice::NetDevice( NetDevicePrivate* _d )
|
||||
: d( _d )
|
||||
{
|
||||
}
|
||||
|
||||
NetDevice::NetDevice( const NetDevice& other )
|
||||
: d( other.d )
|
||||
{
|
||||
}
|
||||
|
||||
QString NetDevice::name() const { return d->name(); }
|
||||
QString NetDevice::hostName() const { return d->hostName(); }
|
||||
QString NetDevice::ipAddress() const { return d->ipAddress(); }
|
||||
QString NetDevice::hostAddress() const { return d->hostAddress(); }
|
||||
NetDevice::Type NetDevice::type() const { return d->type(); }
|
||||
QList<NetService> NetDevice::serviceList() const { return d->serviceList(); }
|
||||
|
||||
|
||||
NetDevice& NetDevice::operator =( const NetDevice& other )
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NetDevice::setDPtr( NetDevicePrivate* _d )
|
||||
{
|
||||
d = _d;
|
||||
}
|
||||
|
||||
NetDevice::~NetDevice()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,101 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETDEVICE_H
|
||||
#define NETDEVICE_H
|
||||
|
||||
// lib
|
||||
#include "molletnetwork_export.h"
|
||||
// KDE
|
||||
#include <KSharedPtr>
|
||||
|
||||
namespace Mollet {
|
||||
class NetService;
|
||||
class NetDevice;
|
||||
}
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QDBusArgument>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern MOLLETNETWORK_EXPORT QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetDevice& device );
|
||||
extern MOLLETNETWORK_EXPORT const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetDevice& device );
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class NetDevicePrivate;
|
||||
|
||||
|
||||
class MOLLETNETWORK_EXPORT NetDevice
|
||||
{
|
||||
friend class DNSSDNetworkBuilder;
|
||||
friend class UpnpNetworkBuilder;
|
||||
#ifndef QT_NAMESPACE
|
||||
friend QDBusArgument& ::operator<<( QDBusArgument& argument, const NetDevice& device );
|
||||
friend const QDBusArgument& ::operator>>( const QDBusArgument& argument, NetDevice& device );
|
||||
#else
|
||||
friend QDBusArgument& ::QT_NAMESPACE::operator<<( QDBusArgument& argument, const NetDevice& device );
|
||||
friend const QDBusArgument& ::QT_NAMESPACE::operator>>( const QDBusArgument& argument, NetDevice& device );
|
||||
#endif
|
||||
|
||||
public:
|
||||
// later has priority
|
||||
enum Type { Unknown = 0, Scanner, Printer, FileServer, Router, Workstation };
|
||||
static QString iconName( Type type );
|
||||
|
||||
public:
|
||||
NetDevice();
|
||||
NetDevice( const NetDevice& other );
|
||||
virtual ~NetDevice();
|
||||
|
||||
public:
|
||||
QString name() const;
|
||||
QString hostName() const;
|
||||
/// if hostName is not set, use ipAddress to identify device
|
||||
QString ipAddress() const;
|
||||
/// returns hostName if set, otherwise ipAddress TODO: find better name
|
||||
QString hostAddress() const;
|
||||
Type type() const;
|
||||
QList<NetService> serviceList() const;
|
||||
|
||||
public:
|
||||
NetDevice& operator =( const NetDevice& other );
|
||||
|
||||
private:
|
||||
NetDevice( NetDevicePrivate* _d );
|
||||
void setDPtr( NetDevicePrivate* _d );
|
||||
NetDevicePrivate* dPtr() const;
|
||||
|
||||
private:
|
||||
KSharedPtr<NetDevicePrivate> d;
|
||||
};
|
||||
|
||||
typedef QList<NetDevice> NetDeviceList;
|
||||
|
||||
|
||||
inline NetDevicePrivate* NetDevice::dPtr() const { return const_cast<NetDevicePrivate*>( d.data() ); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "netdevice_p.h"
|
||||
|
||||
// library
|
||||
#include "netservice_p.h"
|
||||
// Qt
|
||||
#include <QtCore/qlist.h>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
NetDevicePrivate::NetDevicePrivate( const QString& name )
|
||||
: mName( name )
|
||||
, mType( NetDevice::Unknown )
|
||||
{
|
||||
}
|
||||
|
||||
bool NetDevicePrivate::hasService( const QString& id ) const
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
foreach( const NetService& service, mServiceList )
|
||||
{
|
||||
const NetServicePrivate* const d = service.dPtr();
|
||||
if( d->id() == id )
|
||||
{
|
||||
result = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
NetService NetDevicePrivate::removeService( const QString& id )
|
||||
{
|
||||
NetService result;
|
||||
QMutableListIterator<NetService> it( mServiceList );
|
||||
while( it.hasNext())
|
||||
{
|
||||
const NetService& service = it.next();
|
||||
const NetServicePrivate* const d = service.dPtr();
|
||||
if( d->id() == id )
|
||||
{
|
||||
result = service;
|
||||
it.remove();
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
NetDevicePrivate::~NetDevicePrivate()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,85 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETDEVICE_P_H
|
||||
#define NETDEVICE_P_H
|
||||
|
||||
// lib
|
||||
#include "netdevice.h"
|
||||
#include "netservice.h"
|
||||
// Qt
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QString>
|
||||
#include <QtCore/QList>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class NetDevicePrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
explicit NetDevicePrivate( const QString& name );
|
||||
virtual ~NetDevicePrivate();
|
||||
|
||||
public:
|
||||
const QString& name() const;
|
||||
const QString& hostName() const;
|
||||
const QString& ipAddress() const;
|
||||
const QString& hostAddress() const;
|
||||
NetDevice::Type type() const;
|
||||
const QList<NetService>& serviceList() const;
|
||||
bool hasService( const QString& id ) const;
|
||||
|
||||
public:
|
||||
void setName( const QString& name );
|
||||
void setHostName( const QString& hostName );
|
||||
void setIpAddress( const QString& ipAddress );
|
||||
void setType( NetDevice::Type type );
|
||||
void addService( const NetService& service );
|
||||
NetService removeService( const QString& id );
|
||||
|
||||
private:
|
||||
QString mName;
|
||||
QString mHostName;
|
||||
QString mIpAddress;
|
||||
NetDevice::Type mType;
|
||||
QList<NetService> mServiceList;
|
||||
};
|
||||
|
||||
|
||||
inline const QString& NetDevicePrivate::name() const { return mName; }
|
||||
inline const QString& NetDevicePrivate::hostName() const { return mHostName; }
|
||||
inline const QString& NetDevicePrivate::ipAddress() const { return mIpAddress; }
|
||||
inline NetDevice::Type NetDevicePrivate::type() const { return mType; }
|
||||
inline const QList<NetService>& NetDevicePrivate::serviceList() const { return mServiceList; }
|
||||
inline const QString& NetDevicePrivate::hostAddress() const { return mHostName.isEmpty() ? mIpAddress : mHostName; }
|
||||
|
||||
inline void NetDevicePrivate::setName( const QString& name ) { mName = name; }
|
||||
inline void NetDevicePrivate::setHostName( const QString& hostName ) { mHostName = hostName; }
|
||||
inline void NetDevicePrivate::setIpAddress( const QString& ipAddress ) { mIpAddress = ipAddress; }
|
||||
inline void NetDevicePrivate::setType( NetDevice::Type type ) { mType = type; }
|
||||
inline void NetDevicePrivate::addService( const NetService& service ) { mServiceList.append( service ); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,79 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "netservice.h"
|
||||
#include "netservice_p.h"
|
||||
|
||||
// lib
|
||||
#include "netdevice.h"
|
||||
// KDE
|
||||
#include <KGlobal>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
//
|
||||
K_GLOBAL_STATIC_WITH_ARGS(KSharedPtr< NetServicePrivate >,
|
||||
defaultEmptyNetServicePrivate,
|
||||
( new NetServicePrivate(QString(),QString(),QString(),NetDevice(),QString(),QString()) ))
|
||||
|
||||
|
||||
NetService::NetService()
|
||||
: d( *defaultEmptyNetServicePrivate )
|
||||
{
|
||||
}
|
||||
|
||||
NetService::NetService( NetServicePrivate* _d )
|
||||
: d( _d )
|
||||
{
|
||||
}
|
||||
|
||||
NetService::NetService( const NetService& other )
|
||||
: d( other.d )
|
||||
{
|
||||
}
|
||||
|
||||
QString NetService::name() const { return d->name(); }
|
||||
QString NetService::iconName() const { return d->iconName(); }
|
||||
QString NetService::type() const { return d->type(); }
|
||||
NetDevice NetService::device() const { return d->device(); }
|
||||
bool NetService::isValid() const { return !d->type().isEmpty(); } // was !d.isNull()
|
||||
QString NetService::url() const { return d->url(); }
|
||||
|
||||
|
||||
NetService& NetService::operator =( const NetService& other )
|
||||
{
|
||||
d = other.d;
|
||||
return *this;
|
||||
}
|
||||
|
||||
void NetService::setDPtr( NetServicePrivate* _d )
|
||||
{
|
||||
d = _d;
|
||||
}
|
||||
|
||||
NetService::~NetService()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,97 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETSERVICE_H
|
||||
#define NETSERVICE_H
|
||||
|
||||
// lib
|
||||
#include "molletnetwork_export.h"
|
||||
// KDE
|
||||
#include <KSharedPtr>
|
||||
|
||||
namespace Mollet {
|
||||
class NetDevice;
|
||||
class NetService;
|
||||
}
|
||||
#include <QList>
|
||||
#include <QString>
|
||||
#include <QDBusArgument>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
extern MOLLETNETWORK_EXPORT QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetService& service );
|
||||
extern MOLLETNETWORK_EXPORT const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetService& service );
|
||||
QT_END_NAMESPACE
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class NetServicePrivate;
|
||||
|
||||
|
||||
class MOLLETNETWORK_EXPORT NetService
|
||||
{
|
||||
friend class DNSSDNetworkBuilder;
|
||||
friend class UpnpNetworkBuilder;
|
||||
friend class NetDevicePrivate;
|
||||
#ifndef QT_NAMESPACE
|
||||
friend QDBusArgument& ::operator<<( QDBusArgument& argument, const NetService& service );
|
||||
friend const QDBusArgument& ::operator>>( const QDBusArgument& argument, NetService& service );
|
||||
#else
|
||||
friend QDBusArgument& ::QT_NAMESPACE::operator<<( QDBusArgument& argument, const NetService& service );
|
||||
friend const QDBusArgument& ::QT_NAMESPACE::operator>>( const QDBusArgument& argument, NetService& service );
|
||||
#endif
|
||||
|
||||
public:
|
||||
NetService();
|
||||
NetService( const NetService& other );
|
||||
virtual ~NetService();
|
||||
|
||||
public:
|
||||
QString name() const;
|
||||
QString iconName() const;
|
||||
QString type() const;
|
||||
NetDevice device() const;
|
||||
bool isValid() const;
|
||||
|
||||
// TODO: not sure all services come down to one url
|
||||
QString url() const;
|
||||
|
||||
public:
|
||||
NetService& operator =( const NetService& other );
|
||||
|
||||
private:
|
||||
NetService( NetServicePrivate* _d );
|
||||
void setDPtr( NetServicePrivate* _d );
|
||||
NetServicePrivate* dPtr() const;
|
||||
|
||||
private:
|
||||
KSharedPtr<NetServicePrivate> d;
|
||||
};
|
||||
|
||||
typedef QList<NetService> NetServiceList;
|
||||
|
||||
|
||||
inline NetServicePrivate* NetService::dPtr() const { return const_cast<NetServicePrivate*>( d.data() ); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,45 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009,2011 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "netservice_p.h"
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
NetServicePrivate::NetServicePrivate( const QString& name, const QString& iconName, const QString& type,
|
||||
const NetDevice& device, const QString& url, const QString& id )
|
||||
: mName( name )
|
||||
, mIconName( iconName )
|
||||
, mType( type )
|
||||
, mDevice( device )
|
||||
, mUrl( url )
|
||||
, mId( id )
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
NetServicePrivate::~NetServicePrivate()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,71 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009,2011 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETSERVICE_P_H
|
||||
#define NETSERVICE_P_H
|
||||
|
||||
// lib
|
||||
#include "netdevice.h"
|
||||
#include "netservice.h"
|
||||
// Qt
|
||||
#include <QtCore/QSharedData>
|
||||
#include <QtCore/QString>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class NetServicePrivate : public QSharedData
|
||||
{
|
||||
public:
|
||||
explicit NetServicePrivate( const QString& name, const QString& iconName, const QString& type,
|
||||
const NetDevice& device, const QString& url, const QString& id );
|
||||
virtual ~NetServicePrivate();
|
||||
|
||||
public:
|
||||
const QString& name() const;
|
||||
const QString& iconName() const;
|
||||
const QString& type() const;
|
||||
const NetDevice& device() const;
|
||||
const QString& url() const;
|
||||
const QString& id() const;
|
||||
|
||||
private:
|
||||
QString mName;
|
||||
QString mIconName;
|
||||
QString mType;
|
||||
NetDevice mDevice;
|
||||
QString mUrl;
|
||||
QString mId;
|
||||
};
|
||||
|
||||
|
||||
inline const QString& NetServicePrivate::name() const { return mName; }
|
||||
inline const QString& NetServicePrivate::iconName() const { return mIconName; }
|
||||
inline const QString& NetServicePrivate::type() const { return mType; }
|
||||
inline const NetDevice& NetServicePrivate::device() const { return mDevice; }
|
||||
inline const QString& NetServicePrivate::url() const { return mUrl; }
|
||||
inline const QString& NetServicePrivate::id() const { return mId; }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,54 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "network.h"
|
||||
#include "network_p.h"
|
||||
#include "moc_network.cpp"
|
||||
|
||||
// KDE
|
||||
#include <KGlobal>
|
||||
// Qt
|
||||
#include <QtCore/QList>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
Network* Network::network()
|
||||
{
|
||||
K_GLOBAL_STATIC( Network, networkSingleton )
|
||||
return networkSingleton;
|
||||
}
|
||||
|
||||
Network::Network()
|
||||
: d( new NetworkPrivate(this) )
|
||||
{
|
||||
d->init();
|
||||
}
|
||||
|
||||
QList<NetDevice> Network::deviceList() const { return d->deviceList(); }
|
||||
|
||||
Network::~Network()
|
||||
{
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORK_H
|
||||
#define NETWORK_H
|
||||
|
||||
// lib
|
||||
#include "molletnetwork_export.h"
|
||||
// Qt
|
||||
#include <QtCore/QObject>
|
||||
|
||||
namespace Mollet {
|
||||
class NetDevice;
|
||||
class NetService;
|
||||
}
|
||||
#include <QList>
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
class NetworkPrivate;
|
||||
|
||||
class MOLLETNETWORK_EXPORT Network : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
friend class NetworkPrivate;
|
||||
|
||||
public:
|
||||
static Network* network();
|
||||
|
||||
public:
|
||||
virtual ~Network();
|
||||
|
||||
public:
|
||||
QList<NetDevice> deviceList() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void devicesAdded( const QList<NetDevice>& deviceList );
|
||||
void devicesRemoved( const QList<NetDevice>& deviceList );
|
||||
void servicesAdded( const QList<NetService>& serviceList );
|
||||
void servicesRemoved( const QList<NetService>& serviceList );
|
||||
|
||||
void initDone();
|
||||
|
||||
private:
|
||||
Network();
|
||||
Q_PRIVATE_SLOT( d, void onBuilderInit() )
|
||||
|
||||
private:
|
||||
NetworkPrivate* const d;
|
||||
};
|
||||
|
||||
// void connect( Network& network, const char* signal, QObject* object, const char* slot );
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,74 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "network_p.h"
|
||||
|
||||
// lib
|
||||
#include "builder/dnssd/dnssdnetworkbuilder.h"
|
||||
#include "builder/upnp/upnpnetworkbuilder.h"
|
||||
#include "builder/simpleitemfactory.h"
|
||||
|
||||
#include <KDebug>
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
NetworkPrivate::NetworkPrivate( Network* parent )
|
||||
: p( parent )
|
||||
{
|
||||
}
|
||||
|
||||
void NetworkPrivate::init()
|
||||
{
|
||||
SimpleItemFactory* simpleItemFactory = new SimpleItemFactory();
|
||||
mNetSystemFactoryList.append( simpleItemFactory );
|
||||
|
||||
DNSSDNetworkBuilder* dnssdBuilder = new DNSSDNetworkBuilder( this );
|
||||
UpnpNetworkBuilder* upnpBuilder = new UpnpNetworkBuilder( this );
|
||||
mNetworkBuilderList.append( dnssdBuilder );
|
||||
mNetworkBuilderList.append( upnpBuilder );
|
||||
mNoOfInitBuilders = mNetworkBuilderList.count();
|
||||
|
||||
foreach( AbstractNetworkBuilder* builder, mNetworkBuilderList )
|
||||
{
|
||||
foreach( AbstractNetSystemFactory* factory, mNetSystemFactoryList )
|
||||
builder->registerNetSystemFactory( factory );
|
||||
p->connect( builder, SIGNAL(initDone()), SLOT(onBuilderInit()) );
|
||||
builder->start();
|
||||
}
|
||||
}
|
||||
|
||||
void NetworkPrivate::onBuilderInit()
|
||||
{
|
||||
--mNoOfInitBuilders;
|
||||
kDebug()<<mNoOfInitBuilders;
|
||||
if( mNoOfInitBuilders == 0 )
|
||||
emit p->initDone();
|
||||
}
|
||||
|
||||
NetworkPrivate::~NetworkPrivate()
|
||||
{
|
||||
qDeleteAll( mNetworkBuilderList );
|
||||
qDeleteAll( mNetSystemFactoryList );
|
||||
}
|
||||
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORK_P_H
|
||||
#define NETWORK_P_H
|
||||
|
||||
// lib
|
||||
#include "network.h"
|
||||
#include "netdevice.h"
|
||||
|
||||
|
||||
namespace Mollet
|
||||
{
|
||||
|
||||
class AbstractNetworkBuilder;
|
||||
class AbstractNetSystemFactory;
|
||||
|
||||
class NetworkPrivate
|
||||
{
|
||||
public:
|
||||
explicit NetworkPrivate( Network* parent );
|
||||
virtual ~NetworkPrivate();
|
||||
|
||||
public:
|
||||
const QList<NetDevice>& deviceList() const;
|
||||
QList<NetDevice>& deviceList();
|
||||
|
||||
public:
|
||||
void init();
|
||||
void onBuilderInit();
|
||||
|
||||
public:
|
||||
void emitDevicesAdded( const QList<NetDevice>& deviceList );
|
||||
void emitDevicesRemoved( const QList<NetDevice>& deviceList );
|
||||
void emitServicesAdded( const QList<NetService>& serviceList );
|
||||
void emitServicesRemoved( const QList<NetService>& serviceList );
|
||||
|
||||
private: // data
|
||||
Network* p;
|
||||
QList<NetDevice> mDeviceList;
|
||||
QList<AbstractNetworkBuilder*> mNetworkBuilderList;
|
||||
QList<AbstractNetSystemFactory*> mNetSystemFactoryList;
|
||||
|
||||
int mNoOfInitBuilders;
|
||||
};
|
||||
|
||||
|
||||
inline const QList<NetDevice>& NetworkPrivate::deviceList() const { return mDeviceList; }
|
||||
inline QList<NetDevice>& NetworkPrivate::deviceList() { return mDeviceList; }
|
||||
|
||||
inline void NetworkPrivate::emitDevicesAdded( const QList<NetDevice>& deviceList ) { emit p->devicesAdded( deviceList ); }
|
||||
inline void NetworkPrivate::emitDevicesRemoved( const QList<NetDevice>& deviceList ) { emit p->devicesRemoved( deviceList ); }
|
||||
inline void NetworkPrivate::emitServicesAdded( const QList<NetService>& serviceList ) { emit p->servicesAdded( serviceList ); }
|
||||
inline void NetworkPrivate::emitServicesRemoved( const QList<NetService>& serviceList ) { emit p->servicesRemoved( serviceList ); }
|
||||
|
||||
}
|
||||
|
||||
#endif
|
|
@ -1,107 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#include "networkdbus.h"
|
||||
|
||||
// network
|
||||
#include "netdevice_p.h"
|
||||
#include "netservice_p.h"
|
||||
// Qt
|
||||
#include <QtDBus/QDBusArgument>
|
||||
|
||||
|
||||
// TODO: Attention, we currently do not stream any references to other items, just the direct data!
|
||||
QT_BEGIN_NAMESPACE
|
||||
QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetDevice& device )
|
||||
{
|
||||
Mollet::NetDevicePrivate* devicePrivate = device.dPtr();
|
||||
|
||||
argument.beginStructure();
|
||||
argument << devicePrivate->name();
|
||||
argument << devicePrivate->hostName();
|
||||
argument << devicePrivate->ipAddress();
|
||||
argument << (int) devicePrivate->type();
|
||||
argument.endStructure();
|
||||
|
||||
return argument;
|
||||
}
|
||||
const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetDevice& device )
|
||||
{
|
||||
QString name;
|
||||
QString hostName;
|
||||
QString ipAddress;
|
||||
int type;
|
||||
|
||||
argument.beginStructure();
|
||||
argument >> name;
|
||||
argument >> hostName;
|
||||
argument >> ipAddress;
|
||||
argument >> type;
|
||||
argument.endStructure();
|
||||
|
||||
Mollet::NetDevicePrivate* d = new Mollet::NetDevicePrivate( name );
|
||||
d->setHostName( hostName );
|
||||
d->setIpAddress( ipAddress );
|
||||
d->setType( (Mollet::NetDevice::Type)type );
|
||||
|
||||
device.setDPtr( d );
|
||||
|
||||
return argument;
|
||||
}
|
||||
|
||||
QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetService& service )
|
||||
{
|
||||
Mollet::NetServicePrivate* servicePrivate = service.dPtr();
|
||||
|
||||
argument.beginStructure();
|
||||
argument << servicePrivate->name();
|
||||
argument << servicePrivate->iconName();
|
||||
argument << servicePrivate->type();
|
||||
argument << servicePrivate->url();
|
||||
argument << servicePrivate->id();
|
||||
argument.endStructure();
|
||||
|
||||
return argument;
|
||||
}
|
||||
const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetService& service )
|
||||
{
|
||||
QString name;
|
||||
QString iconName;
|
||||
QString type;
|
||||
QString url;
|
||||
QString id;
|
||||
|
||||
argument.beginStructure();
|
||||
argument >> name;
|
||||
argument >> iconName;
|
||||
argument >> type;
|
||||
argument >> url;
|
||||
argument >> id;
|
||||
argument.endStructure();
|
||||
|
||||
Mollet::NetServicePrivate* d = new Mollet::NetServicePrivate( name, iconName, type, Mollet::NetDevice(), url, id );
|
||||
|
||||
service.setDPtr( d );
|
||||
|
||||
return argument;
|
||||
}
|
||||
QT_END_NAMESPACE
|
|
@ -1,53 +0,0 @@
|
|||
/*
|
||||
This file is part of the Mollet network library, part of the KDE project.
|
||||
|
||||
Copyright 2009 Friedrich W. H. Kossebau <kossebau@kde.org>
|
||||
|
||||
This library is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU Lesser General Public
|
||||
License as published by the Free Software Foundation; either
|
||||
version 2.1 of the License, or (at your option) version 3, or any
|
||||
later version accepted by the membership of KDE e.V. (or its
|
||||
successor approved by the membership of KDE e.V.), which shall
|
||||
act as a proxy defined in Section 6 of version 3 of the license.
|
||||
|
||||
This library 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
|
||||
Lesser General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU Lesser General Public
|
||||
License along with this library. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef NETWORKDBUS_H
|
||||
#define NETWORKDBUS_H
|
||||
|
||||
// lib
|
||||
#include "molletnetwork_export.h"
|
||||
#include "netdevice.h"
|
||||
#include "netservice.h"
|
||||
// Qt
|
||||
#include <QtCore/QMetaType>
|
||||
|
||||
|
||||
// TODO: copying single items out of an interlinked structure does not work
|
||||
// classical problem with different address spaces.
|
||||
// instead just the item data is transferred for now. Perhaps this should become another data structure
|
||||
// which uses ids as reference to the linked data. Needs more use cases to get a better picture.
|
||||
// also needed: xml description for introspection and automagical creation of adaptor and interface
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
MOLLETNETWORK_EXPORT QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetDevice& device );
|
||||
MOLLETNETWORK_EXPORT const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetDevice& device );
|
||||
|
||||
MOLLETNETWORK_EXPORT QDBusArgument& operator<<( QDBusArgument& argument, const Mollet::NetService& service );
|
||||
MOLLETNETWORK_EXPORT const QDBusArgument& operator>>( const QDBusArgument& argument, Mollet::NetService& service );
|
||||
QT_END_NAMESPACE
|
||||
|
||||
Q_DECLARE_METATYPE(Mollet::NetDevice)
|
||||
Q_DECLARE_METATYPE(Mollet::NetService)
|
||||
Q_DECLARE_METATYPE(Mollet::NetDeviceList)
|
||||
Q_DECLARE_METATYPE(Mollet::NetServiceList)
|
||||
|
||||
#endif
|
Loading…
Add table
Reference in a new issue