[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kopete-devel
Subject:    [kopete-devel] [PATCHES] Kiosk support for Kopete config
From:       Will Stephenson <wstephenson () kde ! org>
Date:       2008-09-03 22:37:53
Message-ID: 200809040037.53734.wstephenson () kde ! org
[Download RAW message or body]

So it's feature time at SUSE again and I'm developing my patches upstream 
first.  The feature is to "add comprehensive lockdown support to Kopete" and 
this includes
* file transfer
* adding contacts
* allowed protocols
* history
* blocking contacts
* chat window behaviour
* emoticons
* away message behaviour

The attached patches make it possible to 
1) kiosk which protocols can be loaded
2) kiosk which protocols can be seen in the Add Account wizard
3) kiosk customContextMenu() actions in the major protocols (by adding the 
context menu actions to a temporary KActionCollection, since 
KActionCollection::addAction() applies kiosk policy to the KAction objects.
4) Fix kdelibs so that [KDE Control Module Restrictions] lockdown works again

The Kopete-Kiosk-HOWTO rudimentarily explains which keys and desktop files to 
kiosk for which feature.  You'll notice I tried to use action names that are 
standard as much as possible across protocols - I don't see a need to be able 
to lock a feature in one protocol but not another.

Ok to commit? 

Will

PS I have just noticed I missed MSN, I will do the same to it as the other 
protocols if the rest of the patches are ok.

["kopete-kiosk-groupwise.diff" (text/x-patch)]

Index: protocols/groupwise/gwcontact.cpp
===================================================================
--- protocols/groupwise/gwcontact.cpp	(revision 856844)
+++ protocols/groupwise/gwcontact.cpp	(working copy)
@@ -29,6 +29,7 @@
 #include <qmap.h>
 
 #include <kaction.h>
+#include <KActionCollection>
 #include <kdebug.h>
 #include <kicon.h>
 #include <klocale.h>
@@ -159,7 +160,7 @@
 
 QList<KAction*> *GroupWiseContact::customContextMenuActions()
 {
-	QList<KAction *> * actionCollection = new QList<KAction *>;
+	QList<KAction *> * actions = new QList<KAction *>;
 
 	// Block/unblock contact
 	QString label = account()->isContactBlocked( m_dn ) ? i18n( "Unblock User" ) : i18n( "Block User" );
@@ -172,9 +173,12 @@
 		m_actionBlock->setText( label );
 	m_actionBlock->setEnabled( account()->isConnected() );
 
-	actionCollection->append( m_actionBlock );
+	actions->append( m_actionBlock );
+	// temporary action collection, used to apply Kiosk policy to the actions
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("actionBlock"), m_actionBlock);
 
-	return actionCollection;
+	return actions;
 }
 
 void GroupWiseContact::slotUserInfo()

["kopete-kiosk-jabber.diff" (text/x-patch)]

Index: protocols/jabber/jabbercontact.cpp
===================================================================
--- protocols/jabber/jabbercontact.cpp	(revision 856844)
+++ protocols/jabber/jabbercontact.cpp	(working copy)
@@ -31,6 +31,7 @@
 #include <qbuffer.h>
 #include <QList>
 
+#include <KActionCollection>
 #include <kdebug.h>
 #include <klocale.h>
 #include <kmessagebox.h>
@@ -132,7 +133,7 @@
 QList<KAction*> *JabberContact::customContextMenuActions ()
 {
 
-	QList<KAction*> *actionCollection = new QList<KAction*>();
+	QList<KAction*> *actions = new QList<KAction*>();
 
 	KActionMenu *actionAuthorization = new KActionMenu ( KIcon("network-connect"), i18n \
("Authorization"), this);  
@@ -241,16 +242,16 @@
 
 	}
 
-	actionCollection->append( actionAuthorization );
-	actionCollection->append( actionSetAvailability );
-	actionCollection->append( actionSelectResource );
+	actions->append( actionAuthorization );
+	actions->append( actionSetAvailability );
+	actions->append( actionSelectResource );
 	
 	
 #ifdef SUPPORT_JINGLE
 	KAction *actionVoiceCall = new KAction( (i18n ("Voice call"), "voicecall", 0, this, \
SLOT (voiceCall ()), 0, "jabber_voicecall");  actionVoiceCall->setEnabled( false );
 
-	actionCollection->append( actionVoiceCall );
+	actions->append( actionVoiceCall );
 
 	// Check if the current contact support Voice calls, also honor lock by default.
 	JabberResource *bestResource = account()->resourcePool()->bestJabberResource( \
mRosterItem.jid() ); @@ -259,8 +260,16 @@
 		actionVoiceCall->setEnabled( true );
 	}
 #endif
-	
-	return actionCollection;
+
+	// temporary action collection, used to apply Kiosk policy to the actions
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("JabberContactAuthorizationMenu"), \
actionAuthorization); +	tempCollection.addAction(QLatin1String("ContactSendAuth"), \
resendAuthAction); +	tempCollection.addAction(QLatin1String("ContactRequestAuth"), \
requestAuthAction); +	tempCollection.addAction(QLatin1String("ContactRemoveAuth"), \
removeAuthAction); +	tempCollection.addAction(QLatin1String("JabberContactSetAvailabilityMenu"), \
actionSetAvailability); \
+	tempCollection.addAction(QLatin1String("JabberContactSelectResource"), \
actionSelectResource); +	return actions;
 }
 
 void JabberContact::handleIncomingMessage (const XMPP::Message & message)


["kopete-kiosk-libkopete.diff" (text/x-patch)]

Index: libkopete/kopetepluginmanager.cpp
===================================================================
--- libkopete/kopetepluginmanager.cpp	(revision 856844)
+++ libkopete/kopetepluginmanager.cpp	(working copy)
@@ -124,7 +124,7 @@
 	QList<KPluginInfo>::ConstIterator it;
 	for ( it = _kpmp->plugins.begin(); it != _kpmp->plugins.end(); ++it )
 	{
-		if ( it->category() == category )
+		if ( it->category() == category && !(*it).service()->noDisplay() )
 			result.append( *it );
 	}
 
Index: libkopete/kopeteaccountmanager.cpp
===================================================================
--- libkopete/kopeteaccountmanager.cpp	(revision 856844)
+++ libkopete/kopeteaccountmanager.cpp	(working copy)
@@ -344,12 +344,13 @@
 	for ( QStringList::Iterator it = accountGroups.begin(); it != accountGroups.end(); \
++it )  {
 		KConfigGroup cg( config, *it );
+		KConfigGroup pluginConfig( config, QLatin1String("Plugins") );
 
 		QString protocol = cg.readEntry( "Protocol", QString() );
 		if ( protocol.endsWith( QString::fromLatin1( "Protocol" ) ) )
 			protocol = QString::fromLatin1( "kopete_" ) + protocol.toLower().remove( \
QString::fromLatin1( "protocol" ) );  
-		if ( cg.readEntry( "Enabled", true ) )
+		if ( cg.readEntry( "Enabled", true ) && pluginConfig.readEntry(protocol + \
QLatin1String("Enabled"), true) )  PluginManager::self()->loadPlugin( protocol, \
PluginManager::LoadAsync );  }
 }
Index: libkopete/kopeteaccount.cpp
===================================================================
--- libkopete/kopeteaccount.cpp	(revision 856844)
+++ libkopete/kopeteaccount.cpp	(working copy)
@@ -244,6 +244,7 @@
 
 void Account::registerContact( Contact *c )
 {
+	Q_ASSERT(c);
 	d->contacts.insert( c->contactId(), c );
 	QObject::connect( c, SIGNAL( contactDestroyed( Kopete::Contact * ) ),
 		SLOT( contactDestroyed( Kopete::Contact * ) ) );
@@ -251,6 +252,7 @@
 
 void Account::contactDestroyed( Contact *c )
 {
+	Q_ASSERT(c);
 	d->contacts.remove( c->contactId() );
 }
 
@@ -274,7 +276,7 @@
 
 	bool isTemporary = mode == Temporary;
 
-	Contact *c = d->contacts[ contactId ];
+	Contact *c = d->contacts.value( contactId );
 
 	if(!group)
 		group=Group::topLevel();
@@ -339,9 +341,15 @@
 	}
 
 	bool isTemporary= parent->isTemporary();
-	Contact *c = d->contacts[ contactId ];
-	if ( c && c->metaContact() )
+	Contact *c = d->contacts.value( contactId );
+
+	kDebug() << "contactlist has " << d->contacts.count() << " entries";
+	foreach (Contact * t, d->contacts )
 	{
+		kDebug() << "contactlist contains " << t->contactId();
+	}	if ( c && c->metaContact() )
+
+	{
 		if ( c->metaContact()->isTemporary() && !isTemporary )
 		{
 			kDebug( 14010 ) <<


["kopete-kiosk-oscar.diff" (text/x-patch)]

Index: protocols/oscar/aim/aimcontact.cpp
===================================================================
--- protocols/oscar/aim/aimcontact.cpp	(revision 856844)
+++ protocols/oscar/aim/aimcontact.cpp	(working copy)
@@ -17,6 +17,7 @@
 
 #include "aimcontact.h"
 
+#include <KActionCollection>
 #include <klocale.h>
 #include <kdebug.h>
 #include <kmessagebox.h>
@@ -64,7 +65,7 @@
 QList<KAction*> *AIMContact::customContextMenuActions()
 {
 
-	QList<KAction*> *actionCollection = new QList<KAction*>();
+	QList<KAction*> *actions = new QList<KAction*>();
 	if ( !m_warnUserAction )
 	{
 		m_warnUserAction = new KAction( i18n( "&Warn User" ), this );
@@ -90,12 +91,17 @@
 	m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE ));
 	m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE ));
 
-	actionCollection->append( m_warnUserAction );
+	actions->append( m_warnUserAction );
 
-	actionCollection->append(m_actionVisibleTo);
-	actionCollection->append(m_actionInvisibleTo);
+	actions->append(m_actionVisibleTo);
+	actions->append(m_actionInvisibleTo);
 
-	return actionCollection;
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("AIMContactWarn"), m_warnUserAction);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysVisibleTo"), m_actionVisibleTo);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysInvisibleTo"), m_actionInvisibleTo);
+
+	return actions;
 }
 
 int AIMContact::warningLevel() const
Index: protocols/oscar/aim/icqcontact.cpp
===================================================================
--- protocols/oscar/aim/icqcontact.cpp	(revision 856844)
+++ protocols/oscar/aim/icqcontact.cpp	(working copy)
@@ -21,6 +21,7 @@
 
 #include <qtimer.h>
 
+#include <KActionCollection>
 #include <klocale.h>
 #include <krandom.h>
 #include <ktoggleaction.h>
@@ -149,7 +150,7 @@
 
 QList<KAction*> *ICQContact::customContextMenuActions()
 {
-	QList<KAction*> *actionCollection = new QList<KAction*>();
+	QList<KAction*> *actions = new QList<KAction*>();
 
 	m_actionVisibleTo = new KToggleAction(i18n("Always &Visible To"), this );
         //, "actionVisibleTo");
@@ -168,10 +169,14 @@
 	m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE ));
 	m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE ));
 
-	actionCollection->append(m_actionVisibleTo);
-	actionCollection->append(m_actionInvisibleTo);
+	actions->append(m_actionVisibleTo);
+	actions->append(m_actionInvisibleTo);
 
-	return actionCollection;
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysVisibleTo"), m_actionVisibleTo);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysInvisibleTo"), m_actionInvisibleTo);
+
+	return actions;
 }
 
 
Index: protocols/oscar/icq/aimcontact.cpp
===================================================================
--- protocols/oscar/icq/aimcontact.cpp	(revision 856844)
+++ protocols/oscar/icq/aimcontact.cpp	(working copy)
@@ -17,6 +17,7 @@
 
 #include "aimcontact.h"
 
+#include <KActionCollection>
 #include <klocale.h>
 #include <ktoggleaction.h>
 #include <kicon.h>
@@ -88,6 +89,11 @@
 	actionCollection->append(m_actionVisibleTo);
 	actionCollection->append(m_actionInvisibleTo);
 
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("ContactSelectEncoding"), m_selectEncoding);
+	tempCollection.addAction(QLatin1String("ContactIgnore"), m_actionIgnore);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysVisibleTo"), m_actionVisibleTo);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysInvisibleTo"), m_actionInvisibleTo);
 	return actionCollection;
 }
 
Index: protocols/oscar/icq/icqcontact.cpp
===================================================================
--- protocols/oscar/icq/icqcontact.cpp	(revision 856844)
+++ protocols/oscar/icq/icqcontact.cpp	(working copy)
@@ -20,6 +20,7 @@
 #include "icqcontact.h"
 
 #include <qtimer.h>
+#include <KActionCollection>
 #include <klocale.h>
 #include <knotification.h>
 #include <kinputdialog.h>
@@ -552,7 +553,7 @@
 
 QList<KAction*> *ICQContact::customContextMenuActions()
 {
-	QList<KAction*> *actionCollection = new QList<KAction*>();
+	QList<KAction*> *actions = new QList<KAction*>();
 
 	actionRequestAuth = new KAction( i18n("&Request Authorization"), this );
         //, "actionRequestAuth");
@@ -597,15 +598,22 @@
 	m_actionVisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_VISIBLE ));
 	m_actionInvisibleTo->setChecked( ssi->findItem( m_ssiItem.name(), ROSTER_INVISIBLE ));
 
-	actionCollection->append(actionRequestAuth);
-	actionCollection->append(actionSendAuth);
-    actionCollection->append( m_selectEncoding );
+	actions->append(actionRequestAuth);
+	actions->append(actionSendAuth);
+    actions->append( m_selectEncoding );
 
-	actionCollection->append(m_actionIgnore);
-	actionCollection->append(m_actionVisibleTo);
-	actionCollection->append(m_actionInvisibleTo);
+	actions->append(m_actionIgnore);
+	actions->append(m_actionVisibleTo);
+	actions->append(m_actionInvisibleTo);
 
-	return actionCollection;
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("ContactRequestAuth"), actionRequestAuth);
+	tempCollection.addAction(QLatin1String("ContactSendAuth"), actionSendAuth);
+	tempCollection.addAction(QLatin1String("ContactSelectEncoding"), m_selectEncoding);
+	tempCollection.addAction(QLatin1String("ContactIgnore"), m_actionIgnore);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysVisibleTo"), m_actionVisibleTo);
+	tempCollection.addAction(QLatin1String("OscarContactAlwaysInvisibleTo"), m_actionInvisibleTo);
+	return actions;
 }
 
 

["kopete-kiosk-yahoo.diff" (text/x-patch)]

Index: protocols/yahoo/yahoocontact.cpp
===================================================================
--- protocols/yahoo/yahoocontact.cpp	(revision 856844)
+++ protocols/yahoo/yahoocontact.cpp	(working copy)
@@ -46,6 +46,7 @@
 // KDE Includes
 #include <kdebug.h>
 #include <kaction.h>
+#include <KActionCollection>
 #include <kdialog.h>
 #include <klocale.h>
 #include <krun.h>
@@ -374,7 +375,7 @@
 
 QList<KAction*> *YahooContact::customContextMenuActions()
 {
-	QList<KAction*> *actionCollection = new QList<KAction*>();
+	QList<KAction*> *actions = new QList<KAction*>();
 	if ( !m_webcamAction )
 	{
 		m_webcamAction = new KAction( KIcon("webcamreceive"), i18n( "View &Webcam" ), this );
@@ -384,8 +385,8 @@
 		m_webcamAction->setEnabled( true );
 	else
 		m_webcamAction->setEnabled( false );
-	//actionCollection->addAction( "view_webcam", m_webcamAction );
-        actionCollection->append( m_webcamAction );
+	//actions->addAction( "view_webcam", m_webcamAction );
+        actions->append( m_webcamAction );
 
 	if( !m_inviteWebcamAction )
 	{
@@ -396,8 +397,8 @@
 		m_inviteWebcamAction->setEnabled( true );
 	else
 		m_inviteWebcamAction->setEnabled( false );
-	//actionCollection->addAction( "invite_webcam", m_inviteWebcamAction );
-        actionCollection->append( m_inviteWebcamAction );
+	//actions->addAction( "invite_webcam", m_inviteWebcamAction );
+        actions->append( m_inviteWebcamAction );
 
 	if ( !m_buzzAction )
 	{
@@ -408,8 +409,8 @@
 		m_buzzAction->setEnabled( true );
 	else
 		m_buzzAction->setEnabled( false );
-	//actionCollection->addAction( "buzz_contact", m_buzzAction );
-        actionCollection->append( m_buzzAction );
+	//actions->addAction( "buzz_contact", m_buzzAction );
+        actions->append( m_buzzAction );
 
 	if ( !m_stealthAction )
 	{
@@ -420,8 +421,8 @@
 		m_stealthAction->setEnabled( true );
 	else
 		m_stealthAction->setEnabled( false );
-	//actionCollection->addAction( "stealth_contact", m_stealthAction );
-        actionCollection->append( m_stealthAction );
+	//actions->addAction( "stealth_contact", m_stealthAction );
+        actions->append( m_stealthAction );
 
 	if ( !m_inviteConferenceAction )
 	{
@@ -432,8 +433,8 @@
 		m_inviteConferenceAction->setEnabled( true );
 	else
 		m_inviteConferenceAction->setEnabled( false );
-	//actionCollection->addAction( "invite_conference", m_inviteConferenceAction );
-        actionCollection->append( m_inviteConferenceAction );
+	//actions->addAction( "invite_conference", m_inviteConferenceAction );
+        actions->append( m_inviteConferenceAction );
 
 	if ( !m_profileAction )
 	{
@@ -441,10 +442,18 @@
 		connect( m_profileAction, SIGNAL( triggered(bool) ), this, SLOT( slotUserProfile() ) );
 	}
 	m_profileAction->setEnabled( true );
-	//actionCollection->addAction( "profile_contact", m_profileAction );
-        actionCollection->append( m_profileAction );
+	//actions->addAction( "profile_contact", m_profileAction );
+        actions->append( m_profileAction );
 
-	return actionCollection;
+	// temporary action collection, used to apply Kiosk policy to the actions
+	KActionCollection tempCollection((QObject*)0);
+	tempCollection.addAction(QLatin1String("ContactViewWebcam"), m_webcamAction);
+	tempCollection.addAction(QLatin1String("ContactInviteToViewWebcam"), m_inviteWebcamAction);
+	tempCollection.addAction(QLatin1String("ContactBuzz"), m_buzzAction);
+	tempCollection.addAction(QLatin1String("YahooContactStealth"), m_stealthAction);
+	tempCollection.addAction(QLatin1String("YahooContactInviteConference"), m_inviteConferenceAction);
+	tempCollection.addAction(QLatin1String("ContactViewProfile"), m_profileAction);
+	return actions;
 }
 
 void YahooContact::slotUserInfo()

["Kopete-Kiosk-HOWTO" (text/plain)]

file transfer support:
action/contactSendFile=false

contact addition:
action/contactAddContact=false
action/AddContact=false
action/AddGroup=false

allowed protocols:
To lock a protocol on or off:
in kopeterc, set 
[Plugins]
<Pluginname, eg kopete_groupwise>Enabled[$i]=[true|false]
To suppress an (installed) protocol in the Add Account wizard:
in kdeglobals
[KDE Control Module Restrictions][$i]
kopete_jabber.desktop=false
(for example)

history saving:
kopeterc:
[Plugins]
kopete_historyEnabled[$i]=false
(same works for any other plugin)

file transfer support:
action/contactSendFile=false

contact blocking:
msn:
action/actionBlock
groupwise:
action/actionBlock

icq:
action/ContactRequestAuth
action/ContactSendAuth
action/ContactSelectEncoding
action/ContactIgnore
action/OscarContactAlwaysVisibleTo
action/OscarContactAlwaysInvisibleTo

aim:
action/AIMContactWarn
action/OscarContactAlwaysVisibleTo
action/OscarContactAlwaysInvisibleTo

jabber:
action/JabberContactRemoveAuth
not directly related to blocking, but also kioskable now:
action/JabberContactAuthorizationMenu, which contains
  action/ContactSendAuth
  action/ContactRequestAuth
action/JabberContactSetAvailabilityMenu
action/JabberContactSelectResource

yahoo:
ContactInviteToViewWebcam
ContactBuzz
YahooContactStealth
YahooContactInviteConference
ContactViewProfile

* message window behaviour:
[KDE Control Module Restrictions][$i]
kopete_chatwindowconfig.desktop=false
breakage? in kbuildsyscoca or in kservice, need to pass entryPath to \
authorizeControlModule in KService::noDisplay() kopeterc kiosk keys
see kopeteappearancesettings.kcfg for individual keys, lock [Appearance] group for \
total lockdown (affects emoticons too)


* smiley support:
kopeterc
[Appearance]
useEmoticons[i]=false

kdeglobals
[Emoticons]
emoticonsTheme=themename

* away message behaviour:
kopeterc kiosk keys
see kopetebehaviorsettings.kcfg, selected keys:
[Behavior]
useLastAwayMessage=bool
useCustomAwayMessage=bool
autoAwayCustomTitle=string
autoAwayCustomMessage=string



_______________________________________________
kopete-devel mailing list
kopete-devel@kde.org
https://mail.kde.org/mailman/listinfo/kopete-devel


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic