Index: xword/Connectivity/Clients/XWikiClientType.cs =================================================================== --- xword/Connectivity/Clients/XWikiClientType.cs (revision 22805) +++ xword/Connectivity/Clients/XWikiClientType.cs (working copy) @@ -1,23 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace XWiki.Clients -{ - /// - /// Specifies the available client types for connecting to a XWiki server. - /// - public enum XWikiClientType - { - /// - /// The client calls velocity and groovy services via plain HTTP. - /// - HTTP_Client, - - /// - /// The client communicates with the XWiki server using the XML-RPC API. - /// - XML_RPC, - } -} Index: xword/Connectivity/Connectivity.csproj =================================================================== --- xword/Connectivity/Connectivity.csproj (revision 22805) +++ xword/Connectivity/Connectivity.csproj (working copy) @@ -67,7 +67,6 @@ - Index: xword/XWikiLib/XOfficeSettings/XOfficeCommonSettings.cs =================================================================== --- xword/XWikiLib/XOfficeSettings/XOfficeCommonSettings.cs (revision 0) +++ xword/XWikiLib/XOfficeSettings/XOfficeCommonSettings.cs (revision 0) @@ -0,0 +1,58 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using XWiki; + +namespace XWord +{ + /// + /// Structure used for writing and retrieving settings data from Isolated Storage. + /// + [Serializable] + public class XOfficeCommonSettings + { + private string pagesRepository; + private string downloadedAttachmentsRepository; + private XWikiClientType clientType; + + /// + /// Creates a new instance of the class. + /// Used for serialization. + /// + public XOfficeCommonSettings() + { + pagesRepository = Path.GetTempPath(); + downloadedAttachmentsRepository = Path.GetTempPath(); + clientType = XWikiClientType.XML_RPC; + } + + /// + /// Gets or sets the value for the pages repositoy. + /// + public string PagesRepository + { + get { return pagesRepository; } + set { pagesRepository = value; } + } + + /// + /// Gets ot sets the value of the path where the downloaded attachments are stored. + /// + public string DownloadedAttachmentsRepository + { + get { return downloadedAttachmentsRepository; } + set { downloadedAttachmentsRepository = value; } + } + + /// + /// Gets or sets the value for the connetivity type setting. + /// + public XWikiClientType ClientType + { + get { return clientType; } + set { clientType = value; } + } + } +} Index: xword/XWikiLib/XOfficeSettings/XOfficeCommonSettingsHandler.cs =================================================================== --- xword/XWikiLib/XOfficeSettings/XOfficeCommonSettingsHandler.cs (revision 0) +++ xword/XWikiLib/XOfficeSettings/XOfficeCommonSettingsHandler.cs (revision 0) @@ -0,0 +1,132 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.IO.IsolatedStorage; +using System.Linq; +using System.Xml.Serialization; +using System.Runtime.Serialization.Formatters.Binary; +using System.Text; +using XWiki; + +namespace XWord +{ + /// + /// Offers functionality for storing the settings to Isolated Storage. + /// + public class XOfficeCommonSettingsHandler + { + //Isolated storage file name; + static string filename = "XWordSettings"; + + /// + /// Writes the settings to Isolated Storage. + /// + /// The settings to be saved. + /// True if the operation succeded. False if the operation failed. + public static bool WriteRepositorySettings(XOfficeCommonSettings settings) + { + IsolatedStorageFile isFile=null; + IsolatedStorageFileStream stream = null; + BinaryFormatter formatter = null; + + try + { + isFile = IsolatedStorageFile.GetUserStoreForAssembly(); + stream = new IsolatedStorageFileStream(filename, FileMode.Create, isFile); + formatter = new BinaryFormatter(); + formatter.Serialize(stream, settings); + } + catch (IOException ioException) + { + Log.Exception(ioException); + } + finally + { + if (stream != null) + { + stream.Close(); + } + if (isFile != null) + { + isFile.Dispose(); + isFile.Close(); + } + } + return true; + } + + /// + /// Gets the settings from Isolated Storage. + /// + /// A instance containing the settings. + public static XOfficeCommonSettings GetSettings() + { + XOfficeCommonSettings settings=new XOfficeCommonSettings(); + IsolatedStorageFile isFile=null; + IsolatedStorageFileStream stream=null; + BinaryFormatter formatter; + try + { + isFile = IsolatedStorageFile.GetUserStoreForAssembly(); + stream = new IsolatedStorageFileStream(filename, FileMode.Open, isFile); + formatter = new BinaryFormatter(); + settings = (XOfficeCommonSettings)formatter.Deserialize(stream); + } + catch (InvalidCastException ce) + { + Log.ExceptionSummary(ce); + settings = new XOfficeCommonSettings(); + } + catch (Exception ex) + { + Log.ExceptionSummary(ex); + settings = new XOfficeCommonSettings(); + } + finally + { + if (stream != null) + { + stream.Close(); + } + if (isFile != null) + { + isFile.Dispose(); + isFile.Close(); + } + } + return settings; + } + + /// + /// Specifies if the application has the settings saved in Isolated Storage. + /// + /// + /// True is the repository configuration file exists in Isolated Storage. + /// False if the file does not exist. + /// + public static bool HasSettings() + { + IsolatedStorageFile isFile=null; + bool hasSettings=false; + try + { + isFile = IsolatedStorageFile.GetUserStoreForAssembly(); + hasSettings = (isFile.GetFileNames(filename).Length > 0); + } + catch (IOException ioException) + { + Log.Exception(ioException); + } + finally + { + if (isFile != null) + { + isFile.Dispose(); + isFile.Close(); + } + } + + return hasSettings; + } + } +} Index: xword/XWikiLib/XWikiClientType.cs =================================================================== --- xword/XWikiLib/XWikiClientType.cs (revision 0) +++ xword/XWikiLib/XWikiClientType.cs (revision 0) @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; + +namespace XWiki +{ + /// + /// Specifies the available client types for connecting to a XWiki server. + /// + public enum XWikiClientType + { + /// + /// The client calls velocity and groovy services via plain HTTP. + /// + HTTP_Client, + + /// + /// The client communicates with the XWiki server using the XML-RPC API. + /// + XML_RPC, + } +} Index: xword/XWikiLib/XWikiLib.csproj =================================================================== --- xword/XWikiLib/XWikiLib.csproj (revision 22805) +++ xword/XWikiLib/XWikiLib.csproj (working copy) @@ -68,6 +68,9 @@ Settings.settings + + + Index: xword/XWord/AddinSettingsForm.cs =================================================================== --- xword/XWord/AddinSettingsForm.cs (revision 22805) +++ xword/XWord/AddinSettingsForm.cs (working copy) @@ -8,6 +8,7 @@ using System.Windows.Forms; using XWiki.Clients; using XWiki.Logging; +using XWiki; namespace XWord { @@ -23,7 +24,7 @@ bool connectionSettingsApplied = true; bool addinSettingsApplied = true; bool loadingDialogFlag = false; - XWordSettings addinSettings = new XWordSettings(); + XOfficeCommonSettings addinSettings = new XOfficeCommonSettings(); const String connectionDocUrl = "http://xoffice.xwiki.org/xwiki/bin/view/XWord/User_Guide#HConnecttoaXWikiserver"; #region connectivity @@ -136,7 +137,7 @@ loginData.ClearCredentials(); } //Write the settings to isolated storage. - XWordSettingsHandler.WriteRepositorySettings(addinSettings); + XOfficeCommonSettingsHandler.WriteRepositorySettings(addinSettings); this.Cursor = c; } @@ -164,7 +165,7 @@ { Addin.DownloadedAttachmentsRepository = Path.GetTempPath(); } - XWordSettingsHandler.WriteRepositorySettings(addinSettings); + XOfficeCommonSettingsHandler.WriteRepositorySettings(addinSettings); addinSettingsApplied = true; Thread.Sleep(500); this.Cursor = c; @@ -200,7 +201,7 @@ txtUserName.Text = Addin.username; txtPassword.Text = Addin.password; } - addinSettings = new XWordSettings(); + addinSettings = new XOfficeCommonSettings(); addinSettings.PagesRepository = Addin.PagesRepository; addinSettings.DownloadedAttachmentsRepository = Addin.DownloadedAttachmentsRepository; addinSettings.ClientType = Addin.ClientType; Index: xword/XWord/XWikiAddIn.cs =================================================================== --- xword/XWord/XWikiAddIn.cs (revision 22805) +++ xword/XWord/XWikiAddIn.cs (working copy) @@ -564,9 +564,9 @@ this.AddinStatus.Syntax = this.DefaultSyntax; timer = new System.Timers.Timer(TIMER_INTERVAL); //Repositories and temporary files settings - if (XWordSettingsHandler.HasSettings()) + if (XOfficeCommonSettingsHandler.HasSettings()) { - XWordSettings addinSettings = XWordSettingsHandler.GetSettings(); + XOfficeCommonSettings addinSettings = XOfficeCommonSettingsHandler.GetSettings(); this.DownloadedAttachmentsRepository = addinSettings.DownloadedAttachmentsRepository; this.PagesRepository = addinSettings.PagesRepository; this.clientType = addinSettings.ClientType; Index: xword/XWord/XWord.csproj =================================================================== --- xword/XWord/XWord.csproj (revision 22805) +++ xword/XWord/XWord.csproj (working copy) @@ -266,8 +266,6 @@ Settings.settings True - - Index: xword/XWord/XWordSettings.cs =================================================================== --- xword/XWord/XWordSettings.cs (revision 22805) +++ xword/XWord/XWordSettings.cs (working copy) @@ -1,58 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.Linq; -using System.Text; -using XWiki.Clients; - -namespace XWord -{ - /// - /// Structure used for writing and retrieving settings data from Isolated Storage. - /// - [Serializable] - public class XWordSettings - { - private string pagesRepository; - private string downloadedAttachmentsRepository; - private XWikiClientType clientType; - - /// - /// Creates a new instance of the class. - /// Used for serialization. - /// - public XWordSettings() - { - pagesRepository = Path.GetTempPath(); - downloadedAttachmentsRepository = Path.GetTempPath(); - clientType = XWikiClientType.XML_RPC; - } - - /// - /// Gets or sets the value for the pages repositoy. - /// - public string PagesRepository - { - get { return pagesRepository; } - set { pagesRepository = value; } - } - - /// - /// Gets ot sets the value of the path where the downloaded attachments are stored. - /// - public string DownloadedAttachmentsRepository - { - get { return downloadedAttachmentsRepository; } - set { downloadedAttachmentsRepository = value; } - } - - /// - /// Gets or sets the value for the connetivity type setting. - /// - public XWikiClientType ClientType - { - get { return clientType; } - set { clientType = value; } - } - } -} Index: xword/XWord/XWordSettingsHandler.cs =================================================================== --- xword/XWord/XWordSettingsHandler.cs (revision 22805) +++ xword/XWord/XWordSettingsHandler.cs (working copy) @@ -1,132 +0,0 @@ -using System; -using System.Collections.Generic; -using System.IO; -using System.IO.IsolatedStorage; -using System.Linq; -using System.Xml.Serialization; -using System.Runtime.Serialization.Formatters.Binary; -using System.Text; -using XWiki; - -namespace XWord -{ - /// - /// Offers functionality for storing the settings to Isolated Storage. - /// - public class XWordSettingsHandler - { - //Isolated storage file name; - static string filename = "XWordSettings"; - - /// - /// Writes the settings to Isolated Storage. - /// - /// The settings to be saved. - /// True if the operation succeded. False if the operation failed. - public static bool WriteRepositorySettings(XWordSettings settings) - { - IsolatedStorageFile isFile=null; - IsolatedStorageFileStream stream = null; - BinaryFormatter formatter = null; - - try - { - isFile = IsolatedStorageFile.GetUserStoreForAssembly(); - stream = new IsolatedStorageFileStream(filename, FileMode.Create, isFile); - formatter = new BinaryFormatter(); - formatter.Serialize(stream, settings); - } - catch (IOException ioException) - { - Log.Exception(ioException); - } - finally - { - if (stream != null) - { - stream.Close(); - } - if (isFile != null) - { - isFile.Dispose(); - isFile.Close(); - } - } - return true; - } - - /// - /// Gets the settings from Isolated Storage. - /// - /// A instance containing the settings. - public static XWordSettings GetSettings() - { - XWordSettings settings=new XWordSettings(); - IsolatedStorageFile isFile=null; - IsolatedStorageFileStream stream=null; - BinaryFormatter formatter; - try - { - isFile = IsolatedStorageFile.GetUserStoreForAssembly(); - stream = new IsolatedStorageFileStream(filename, FileMode.Open, isFile); - formatter = new BinaryFormatter(); - settings = (XWordSettings)formatter.Deserialize(stream); - } - catch (InvalidCastException ce) - { - Log.ExceptionSummary(ce); - settings = new XWordSettings(); - } - catch (Exception ex) - { - Log.ExceptionSummary(ex); - settings = new XWordSettings(); - } - finally - { - if (stream != null) - { - stream.Close(); - } - if (isFile != null) - { - isFile.Dispose(); - isFile.Close(); - } - } - return settings; - } - - /// - /// Specifies if the application has the settings saved in Isolated Storage. - /// - /// - /// True is the repository configuration file exists in Isolated Storage. - /// False if the file does not exist. - /// - public static bool HasSettings() - { - IsolatedStorageFile isFile=null; - bool hasSettings=false; - try - { - isFile = IsolatedStorageFile.GetUserStoreForAssembly(); - hasSettings = (isFile.GetFileNames(filename).Length > 0); - } - catch (IOException ioException) - { - Log.Exception(ioException); - } - finally - { - if (isFile != null) - { - isFile.Dispose(); - isFile.Close(); - } - } - - return hasSettings; - } - } -}