OSDN Git Service

na-get-lib,all-get,インストール除外リストの設定を追加。all-get.exeのcheckupgrade表示への反映
[applistation/AppliStation.git] / na-get-lib / NaGet / Env.cs
index ed39c9d..f2fc17b 100644 (file)
@@ -24,11 +24,36 @@ namespace NaGet
                private static NaGetLibPref pref;\r
                \r
                /// <summary>\r
-               /// 設定ファイルを読み込む。一回のみ呼ばれる\r
+               /// 設定(のクローンオブジェクト)を返す\r
                /// </summary>\r
-               private static void loadPref()\r
+               public static NaGetLibPref Pref {\r
+                       get {\r
+                               NaGetLibPref prefCopied = new NaGetLibPref();\r
+                               \r
+                               if (pref == null) {\r
+                                       LoadPref();\r
+                               }\r
+                               NaGet.Utils.FieldCopy(pref, ref prefCopied);\r
+                               \r
+                               return prefCopied;\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// 設定ファイルのある場所を取得する\r
+               /// </summary>\r
+               public static string PrefPath {\r
+                       get {\r
+                               return Path.Combine(Environment.CurrentDirectory, "pref.xml");\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// 設定ファイルを読み込む。または再読み込みする。\r
+               /// </summary>\r
+               public static void LoadPref()\r
                {\r
-                       string path = Path.Combine(Environment.CurrentDirectory, "pref.xml");\r
+                       string path = PrefPath;\r
                        try {\r
                                if (! File.Exists(path)) throw new FileNotFoundException(string.Empty, path);\r
                                pref = NaGet.Utils.GetDeserializedObject<NaGetLibPref>(path);\r
@@ -37,16 +62,11 @@ namespace NaGet
                        }\r
                }\r
                \r
+               \r
                #endregion\r
 \r
                #region ファイルパス\r
                \r
-               /// <summary>           \r
-               /// ファイルリスト提供サーバのリストファイル        \r
-               /// </summary>\r
-               [Obsolete]\r
-               public static readonly string ProviderListFile = "provider.list.txt";\r
-               \r
                /// <summary>\r
                /// ファイルリスト提供レポジトリリストのファイル\r
                /// </summary>\r
@@ -73,12 +93,12 @@ namespace NaGet
                public static readonly string SystemInstalledPackageLogFile = "packages.sysinstalled.log.xml";\r
                \r
                /// <summary>\r
-               /// アプリケーションデータを保存するフォルダのパス\r
+               /// ã\82¢ã\83\97ã\83ªã\82±ã\83¼ã\82·ã\83§ã\83³ã\83\87ã\83¼ã\82¿ã\82\92ä¿\9då­\98ã\81\99ã\82\8bã\83\95ã\82©ã\83«ã\83\80ã\83¼ã\81®ã\83\91ã\82¹\r
                /// </summary>\r
                public static string AppDataFolderPath\r
                {\r
                        get {\r
-                               if (pref == null) loadPref();\r
+                               if (pref == null) LoadPref();\r
                                \r
                                if (! string.IsNullOrEmpty(pref.AppDataFolder)) {\r
                                        return pref.AppDataFolder;\r
@@ -89,15 +109,24 @@ namespace NaGet
                }\r
 \r
                /// <summary>\r
-               /// インストーラの一時置き場の親ディレクトリ\r
+               /// ã\82¤ã\83³ã\82¹ã\83\88ã\83¼ã\83©ã\83¼ã\81®ä¸\80æ\99\82ç½®ã\81\8då ´ã\81®è¦ªã\83\87ã\82£ã\83¬ã\82¯ã\83\88ã\83ª\r
                /// </summary>\r
                public static string ArchiveFolderPath\r
                {\r
-                       get { return Path.Combine(AppDataFolderPath, "Cache"); }\r
+                       get {\r
+                               if (pref == null) LoadPref();\r
+\r
+                               if (! string.IsNullOrEmpty(pref.CacheFolder)) {\r
+                                       return pref.CacheFolder;\r
+                               }\r
+                               \r
+                               return Path.Combine(AppDataFolderPath, "Cache");\r
+                       \r
+                       }\r
                }\r
                \r
                /// <summary>\r
-               /// アーカイバ方式のパッケージのインストール先フォルダ\r
+               /// アーカイバ方式のパッケージのインストール先フォルダ\r
                /// </summary>\r
                public static string ArchiveProgramFiles {\r
                        get {\r
@@ -106,7 +135,7 @@ namespace NaGet
                }\r
                \r
                /// <summary>\r
-               /// アーカイバ方式のパッケージのプログラムグループフォルダ\r
+               /// アーカイバ方式のパッケージのプログラムグループフォルダ\r
                /// </summary>\r
                public static string ArchiveProgramGroup {\r
                        get {\r
@@ -115,7 +144,7 @@ namespace NaGet
                }\r
 \r
                /// <summary>\r
-               /// アーカイバ方式のパッケージのSystem32のフォルダ\r
+               /// アーカイバ方式のパッケージのSystem32のフォルダ\r
                /// </summary>\r
                public static string ArchiveSystem32 {\r
                        get {\r
@@ -134,7 +163,7 @@ namespace NaGet
                public static IWebProxy WebProxy\r
                {\r
                        get {\r
-                               if (pref == null) loadPref();\r
+                               if (pref == null) LoadPref();\r
                                \r
                                if (string.IsNullOrEmpty(pref.ProxyAddress)) {\r
                                        // 設定されていないときはシステムのデフォルトを使う\r
@@ -144,11 +173,75 @@ namespace NaGet
                                        return null;\r
                                } else {\r
                                        // host:portが設定されているならば、それをもとに設定\r
-                                       return new WebProxy(pref.ProxyAddress);\r
+                                       WebProxy proxy = new WebProxy(pref.ProxyAddress);\r
+                                       \r
+                                       // 認証プロキシの場合、認証情報を付加する\r
+                                       try {\r
+                                               Uri uri = new Uri(pref.ProxyAddress);\r
+                                               if (! string.IsNullOrEmpty(uri.UserInfo)) {\r
+                                                       int pos = uri.UserInfo.IndexOf(':');\r
+                                                       if (pos >= 0) {\r
+                                                               proxy.Credentials = new NetworkCredential(\r
+                                                                       uri.UserInfo.Substring(0, pos),\r
+                                                                       uri.UserInfo.Substring(pos+1)\r
+                                                               );\r
+                                                       }\r
+                                               }\r
+                                       } catch (Exception) {\r
+                                       }\r
+                                       \r
+                                       return proxy;\r
                                }\r
                        }\r
                }\r
                \r
                #endregion\r
+               \r
+               #region インストールプロセス\r
+               \r
+               /// <summary>\r
+               /// インストーラーをウイルススキャンするか?\r
+               /// </summary>\r
+               public static bool EnableScanInstallerFile {\r
+                       get {\r
+                               if (pref == null) LoadPref();\r
+                               return pref.EnableScanInstallerFile;\r
+                       }\r
+                       set {\r
+                               if (pref == null) LoadPref();\r
+                               pref.EnableScanInstallerFile = value;\r
+                       }\r
+               }\r
+\r
+               /// <summary>\r
+               /// インストールプロセスをバックグラウンドで行うか?\r
+               /// </summary>\r
+               public static bool InstallProcessOnBackground {\r
+                       get {\r
+                               if (pref == null) LoadPref();\r
+                               return pref.InstallOnBackground;\r
+                       }\r
+                       set {\r
+                               if (pref == null) LoadPref();\r
+                               pref.EnableScanInstallerFile = value;\r
+                       }\r
+               }\r
+               \r
+               /// <summary>\r
+               /// アップデートから除外するパッケージの名前\r
+               /// </summary>\r
+               public static string[] ExcludeUpdatePackageNames {\r
+                       get {\r
+                               if (pref == null) LoadPref();\r
+                               return pref.ExcludeUpdatePackageNames;\r
+                       }\r
+                       set {\r
+                               if (pref == null) LoadPref();\r
+                               pref.ExcludeUpdatePackageNames = value;\r
+                       }\r
+               }\r
+               \r
+               #endregion\r
+               \r
        }\r
 }\r