diff options
author | Mikhail Voitenko <mav@openoffice.org> | 2008-02-11 09:31:30 +0000 |
---|---|---|
committer | Mikhail Voitenko <mav@openoffice.org> | 2008-02-11 09:31:30 +0000 |
commit | dd58971fa01923051208ffc6c0ce8a4569933bf4 (patch) | |
tree | 3afbbd81633cecdc1ba84f82bc77a137f7f2f4c7 /swext | |
parent | 1abd836201dd66b93a648c58ee929cfc45e170d7 (diff) |
store the user name
Diffstat (limited to 'swext')
4 files changed, 47 insertions, 40 deletions
diff --git a/swext/mediawiki/src/com/sun/star/wiki/Helper.java b/swext/mediawiki/src/com/sun/star/wiki/Helper.java index a31d6ac13182..cc2e2e5df070 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Helper.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Helper.java @@ -4,9 +4,9 @@ * * $RCSfile: Helper.java,v $ * - * $Revision: 1.17 $ + * $Revision: 1.18 $ * - * last change: $Author: mav $ $Date: 2008-02-11 08:35:34 $ + * last change: $Author: mav $ $Date: 2008-02-11 10:31:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -866,12 +866,19 @@ public class Helper } } - protected static UrlRecord GetUsersForURL( XComponentContext xContext, String sURL ) + protected static String[] GetPasswordsForURLAndUser( XComponentContext xContext, String sURL, String sUserName ) { - UrlRecord aResult = null; + String[] aResult = null; + try { - aResult = GetPasswordContainer( xContext ).find( sURL, GetInteractionHandler( xContext ) ); + if ( xContext != null && sURL != null && sURL.length() > 0 && sUserName != null && sUserName.length() > 0 ) + { + UrlRecord aRec = GetPasswordContainer( xContext ).findForName( sURL, sUserName, GetInteractionHandler( xContext ) ); + if ( aRec != null && aRec.UserList != null && aRec.UserList.length > 0 + && aRec.UserList[0].UserName.equals( sUserName ) ) + aResult = aRec.UserList[0].Passwords; + } } catch( Exception e ) { diff --git a/swext/mediawiki/src/com/sun/star/wiki/Settings.java b/swext/mediawiki/src/com/sun/star/wiki/Settings.java index 3181dd658842..8fc2d410efc2 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/Settings.java +++ b/swext/mediawiki/src/com/sun/star/wiki/Settings.java @@ -4,9 +4,9 @@ * * $RCSfile: Settings.java,v $ * - * $Revision: 1.3 $ + * $Revision: 1.4 $ * - * last change: $Author: mav $ $Date: 2008-02-11 08:35:34 $ + * last change: $Author: mav $ $Date: 2008-02-11 10:31:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -35,11 +35,12 @@ package com.sun.star.wiki; +import com.sun.star.beans.XPropertySet; import com.sun.star.container.XNameAccess; import com.sun.star.container.XNameContainer; import com.sun.star.container.XNameReplace; import com.sun.star.lang.XSingleServiceFactory; -import com.sun.star.task.UrlRecord; +import com.sun.star.uno.AnyConverter; import com.sun.star.uno.UnoRuntime; import com.sun.star.uno.XComponentContext; import com.sun.star.util.XChangesBatch; @@ -228,7 +229,12 @@ public class Settings { Object oNewConnection = xConnectionFactory.createInstance(); Hashtable ht = ( Hashtable ) m_WikiConnections.get( i ); - xContainer.insertByName( (String)ht.get( "Url" ), oNewConnection ); + XNameReplace xNewConn = ( XNameReplace ) UnoRuntime.queryInterface( XNameReplace.class, oNewConnection ); + + if ( xNewConn != null ) + xNewConn.replaceByName( "UserName", ht.get( "Username" ) ); + + xContainer.insertByName( (String)ht.get( "Url" ), xNewConn ); } // commit changes XChangesBatch xBatch = ( XChangesBatch ) UnoRuntime.queryInterface( XChangesBatch.class, xContainer ); @@ -291,15 +297,26 @@ public class Settings ht.put( "Username", "" ); ht.put( "Password", "" ); - //TODO/LATER: how to handle more than one user? - // for now use the first one - UrlRecord aRecord = Helper.GetUsersForURL( m_xContext, allCons[i] ); - if ( aRecord != null && aRecord.UserList != null && aRecord.UserList.length > 0 ) + try { - ht.put( "Username", aRecord.UserList[0] ); - if ( aRecord.UserList[0].Passwords != null && aRecord.UserList[0].Passwords.length > 0 ) - ht.put( "Password", aRecord.UserList[0].Passwords[0] ); + XPropertySet xProps = (XPropertySet)UnoRuntime.queryInterface( XPropertySet.class, xConnectionList.getByName( allCons[i] ) ); + if ( xProps != null ) + { + String aUsername = AnyConverter.toString( xProps.getPropertyValue( "UserName" ) ); + if ( aUsername != null && aUsername.length() > 0 ) + { + ht.put( "Username", aUsername ); + String[] pPasswords = Helper.GetPasswordsForURLAndUser( m_xContext, allCons[i], aUsername ); + if ( pPasswords != null && pPasswords.length > 0 ) + ht.put( "Password", pPasswords[0] ); + } + } } + catch( Exception e ) + { + e.printStackTrace(); + } + addWikiCon( ht ); } diff --git a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java index de6b8d540987..a242f4e2c97f 100644 --- a/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java +++ b/swext/mediawiki/src/com/sun/star/wiki/WikiArticle.java @@ -4,9 +4,9 @@ * * $RCSfile: WikiArticle.java,v $ * - * $Revision: 1.6 $ + * $Revision: 1.7 $ * - * last change: $Author: mav $ $Date: 2008-02-10 15:56:36 $ + * last change: $Author: mav $ $Date: 2008-02-11 10:31:29 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -83,24 +83,7 @@ public class WikiArticle // loginURL = sMainUrl + "index.php?title=Special:Userlogin"; // loginSubmitURL = sMainUrl + "index.php?title=Special:Userlogin&action=submitlogin"; - boolean bGotLogin = false; - if ( bLogin && m_sWikiUser.equals( "" ) && m_sWikiPass.equals( "" ) ) - { - UrlRecord aRecord = Helper.GetUsersForURL( m_xContext, m_aMainURI.toString() ); - // TODO: there could be more users available, it should probably be possible to select from them - // from other side, asking each time for the user name could disturb the user - // For now the first acceptable user will be used. - if ( aRecord != null && aRecord.UserList != null ) - for ( int nUserInd = 0; !bGotLogin && nUserInd < aRecord.UserList.length; nUserInd++ ) - for ( int nPassInd = 0; !bGotLogin && nPassInd < aRecord.UserList[nUserInd].Passwords.length; nPassInd++ ) - { - m_sWikiUser = aRecord.UserList[nUserInd].UserName; - m_sWikiPass = aRecord.UserList[nUserInd].Passwords[nPassInd]; - bGotLogin = Login(); - } - } - - if ( bLogin && !bGotLogin ) + if ( bLogin ) { WikiEditSettingDialog aDialog = new WikiEditSettingDialog(m_xContext, "vnd.sun.star.script:WikiEditor.EditSetting?location=application", wikiSettings, false ); try diff --git a/swext/mediawiki/src/registry/schema/org/openoffice/Office/Custom/WikiExtension.xcs b/swext/mediawiki/src/registry/schema/org/openoffice/Office/Custom/WikiExtension.xcs index 23d5c6732728..09ec51322310 100644 --- a/swext/mediawiki/src/registry/schema/org/openoffice/Office/Custom/WikiExtension.xcs +++ b/swext/mediawiki/src/registry/schema/org/openoffice/Office/Custom/WikiExtension.xcs @@ -5,9 +5,9 @@ * * $RCSfile: WikiExtension.xcs,v $ * - * $Revision: 1.1 $ + * $Revision: 1.2 $ * - * last change: $Author: mav $ $Date: 2008-02-08 14:32:21 $ + * last change: $Author: mav $ $Date: 2008-02-11 10:31:30 $ * * The Contents of this file are made available subject to * the terms of GNU Lesser General Public License Version 2.1. @@ -64,8 +64,8 @@ <group oor:name="ConnectionURL"> <info><desc>The name of the entry is a connection URL of a wiki server.</desc></info> - <prop oor:name="UnusedString" oor:type="xs:string"> - <info><desc>The UnusedString is necessary, since the current configuration accepts only structs in sets</desc></info> + <prop oor:name="UserName" oor:type="xs:string"> + <info><desc>The UserName that is used to access the URL.</desc></info> </prop> </group> |