OSDN Git Service

Beログイン仕様変更に対応
[gikonavigoeson/gikonavi.git] / Setting.pas
index 49c5730..cfbf9ec 100644 (file)
@@ -414,7 +414,7 @@ type
                                //Be2ch
                 //\94F\8fØ\97p\83\86\81[\83UID\81E\83p\83X\83\8f\81[\83h
                FBeUserID: String;
-               FBeCode: String;
+               FBePassword: String;
                FBeAutoLogin: Boolean;
                FBeLogin: Boolean;
                //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\8c\8f\90\94
@@ -466,6 +466,10 @@ type
         FRespopupMailTo: Boolean;
         //! \8cë\94\9a\83`\83F\83b\83N
         FUseGobakuCheck: Boolean;
+
+        //! \96`\8c¯\82Ì\8f\91\97pCookie
+        FBoukenCookieList: TStringList;
+
                function GetMainCoolSet(Index: Integer): TCoolSet;
                function GetBoardCoolSet(Index: Integer): TCoolSet;
                function GetBrowserCoolSet(Index: Integer): TCoolSet;
@@ -516,6 +520,7 @@ type
                procedure WriteNameMailSettingFile;
                procedure WriteFolderSettingFile();
                procedure WriteBoardURLSettingFile;
+               procedure WriteBoukenSettingFile;
                function GetSoundCount: Integer;
                function FindSoundFileName(Name: string): string;
 
@@ -543,6 +548,9 @@ type
                function GetInputAssistFileName : String;
         function GetReplaceFileName: String;
         function GetExtprevieFileName: String;
+        function GetBoukenCookie(AHostName: String): String;
+        procedure SetBoukenCookie(ACookieValue, AHostName: String);
+        procedure GetBouken(AHostName: String; var Domain:String; var Cookie:String);
         {
         \brief  \83\8a\83\93\83N\97\9a\97ð\82Ì\95Û\8e\9d\83T\83C\83Y\82Ìsetter
         \param  AVal    \90Ý\92è\82·\82é\83T\83C\83Y( >0)
@@ -792,7 +800,7 @@ type
                property UseUndecided: Boolean read FUseUndecided write FUseUndecided;
 
                property BeUserID: string read FBeUserID write FBeUserID;
-               property BeCode: string read FBeCode write FBeCode;
+               property BePassword: string read FBePassword write FBePassword;
                property BeAutoLogin: Boolean read FBeAutoLogin write FBeAutoLogin;
                property BeLogin: Boolean read FBeLogin write FBeLogin;
                property MaxRecordCount : Integer read FMaxRecordCount write FMaxRecordCount;
@@ -837,7 +845,9 @@ type
         property RespopupWait: Integer read FRespopupWait write FRespopupWait;
         property RespopupMailTo: Boolean read FRespopupMailTo write FRespopupMailTo;
         //! \8cë\94\9a\83`\83F\83b\83N
-        property UseGobakuCheck: Boolean read FUseGobakuCheck write FUseGobakuCheck; 
+        property UseGobakuCheck: Boolean read FUseGobakuCheck write FUseGobakuCheck;
+        //! \96`\8c¯\82Ì\8f\91
+        property BoukenCookieList: TStringList read FBoukenCookieList write FBoukenCookieList; 
 end;
 
 
@@ -996,6 +1006,7 @@ begin
        FMailList.Duplicates := dupIgnore;
        FBoardURLs.Duplicates := dupIgnore;
        FSelectTextList.Duplicates := dupIgnore;
+    FBoukenCookieList := TStringList.Create;
        ReadSettingFile();
        ReadBoardURLsFile();
 end;
@@ -1003,6 +1014,7 @@ end;
 //\83f\83X\83g\83\89\83N\83^
 destructor TSetting.Destroy();
 begin
+    FBoukenCookieList.Free;
        FBoardColumnOrder.Free;
        FCategoryColumnOrder.Free;
        FBBSColumnOrder.Free;
@@ -1036,6 +1048,7 @@ var
        s: string;                                               
        CoolSet: TCoolSet;
     msg: String;
+    hostList: TStringList;
 begin
        Exists := FileExists(GetFileName);
        ini := TMemIniFile.Create(GetFileName);
@@ -1225,6 +1238,7 @@ begin
 
                //\83T\83E\83\93\83h
                if Exists then begin
+            SetCurrentDir(ExtractFilePath(Application.ExeName));
                        for i := 0 to GetSoundCount - 1 do begin
                                SoundFileName[i] := ini.ReadString('Sound', SoundName[i], '');
                 // \91\8a\91Î\8eQ\8fÆ\91Î\8dô
@@ -1302,7 +1316,7 @@ begin
         //Be2ch
                //\94F\8fØ\97p\83\86\81[\83UID\81E\94F\8fØ\83R\81[\83h
                FBeUserID := ini.ReadString('Be', 'UserID', '');
-               FBeCode := Decrypt(ini.ReadString('Be', 'Code', ''));
+               FBePassword := Decrypt(ini.ReadString('Be', 'Password', ''));
                FBeAutoLogin := ini.ReadBool('Be', 'AutoLogin', False);
                //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\8c\8f\90\94
                FMaxRecordCount := Max(ini.ReadInteger('Recode', 'Max', 100), 1);
@@ -1339,7 +1353,14 @@ begin
         FCheckDatFile := ini.ReadBool('ThreadList', 'CheckDatFile', True);
         FLimitResCountMessage := ini.ReadBool('Thread', 'LimitResCountMessage', True);
 
-
+        // \96`\8c¯\82Ì\8f\91Cookie\93Ç\82Ý\8d\9e\82Ý
+        hostList := TStringList.Create;
+        ini.ReadSection('Bouken', hostList);
+        for i := 0 to hostList.Count - 1 do begin
+            FBoukenCookieList.Add( hostList[i] + '=' +
+                ini.ReadString('Bouken', hostList[i], '') );
+        end;
+        hostList.Free;
 
         // \83M\83R\83i\83r\8dX\90V\82Å\97\98\97p\82µ\82½\83C\83\93\83X\83g\81[\83\89\82Ì\8dí\8f\9c
         s := ini.ReadString('Update', 'Remove0', '');
@@ -1720,7 +1741,7 @@ begin
 
                //\94F\8fØ\97p\83\86\81[\83UID\81E\83p\83X\83\8f\81[\83h
                ini.WriteString('Be', 'UserID', FBeUserID);
-               ini.WriteString('Be', 'Code', Encrypt(FBeCode));
+               ini.WriteString('Be', 'Password', Encrypt(FBePassword));
                ini.WriteBool('Be', 'AutoLogin', FBeAutoLogin);
 
                //\97\9a\97ð\82Ì\8dÅ\91å\95Û\91\8c\8f\90\94
@@ -1740,6 +1761,25 @@ begin
         ini.WriteBool('ThreadList', 'CheckDatFile', FCheckDatFile);
         ini.WriteBool('Thread', 'LimitResCountMessage', FLimitResCountMessage);
 
+
+               ini.UpdateFile;
+       finally
+               ini.Free;
+       end;
+end;
+//\90Ý\92è\83t\83@\83C\83\8b\95Û\91¶(\96`\8c¯\82Ì\8f\91)
+procedure TSetting.WriteBoukenSettingFile;
+var
+       i: Integer;
+       ini: TMemIniFile;
+begin
+       ini := TMemIniFile.Create(GetFileName());
+       try
+               ini.EraseSection('Bouken');
+        // \96`\8c¯\82Ì\8f\91Cookie\8f\91\82«\8d\9e\82Ý
+        for i := 0 to FBoukenCookieList.Count - 1 do begin
+            ini.WriteString('Bouken', FBoukenCookieList.Names[i], FBoukenCookieList.Values[FBoukenCookieList.Names[i]]);
+        end;
                ini.UpdateFile;
        finally
                ini.Free;
@@ -2439,6 +2479,44 @@ function TSetting.GetCSSFileName: string;
 begin
     Result := FSkinFiles.FileName;
 end;
+function TSetting.GetBoukenCookie(AHostName: String): String;
+var
+    i : Integer;
+begin
+    for i := 0 to FBoukenCookieList.Count - 1 do begin
+        if ( AnsiPos(FBoukenCookieList.Names[i], AHostName) > 0 ) then begin
+            Result := FBoukenCookieList.Values[FBoukenCookieList.Names[i]];
+            Break;
+        end;
+    end;
+end;
+procedure TSetting.SetBoukenCookie(ACookieValue, AHostName: String);
+var
+    i : Integer;
+begin
+    for i := 0 to FBoukenCookieList.Count - 1 do begin
+        if ( FBoukenCookieList.Names[i] = AHostName ) then begin
+            FBoukenCookieList[i] := AHostName + '=' + ACookieValue;
+            Break;
+        end;
+    end;
+    if ( i = FBoukenCookieList.Count ) then begin
+        FBoukenCookieList.Add(AHostName + '=' + ACookieValue);
+    end;
+end;
+procedure TSetting.GetBouken(AHostName: String; var Domain:String; var Cookie:String);
+var
+    i : Integer;
+begin
+    Cookie := '';
+    for i := 0 to FBoukenCookieList.Count - 1 do begin
+        if ( AnsiPos(FBoukenCookieList.Names[i], AHostName) > 0 ) then begin
+            Domain := FBoukenCookieList.Names[i];
+            Cookie := FBoukenCookieList.Values[FBoukenCookieList.Names[i]];
+            Break;
+        end;
+    end;
+end;
 
 end.