Example #1
0
        private void browserBehind_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            try
            {
                System.Collections.Specialized.NameValueCollection query = System.Web.HttpUtility.ParseQueryString(e.Url.Query);

                if (query.Get("a") == "log.naver")                     // 위에 로고를 클릭함.
                {
                    e.Cancel = true;
                    this.browserBehind.Navigate("https://nid.naver.com/nidlogin.login?svctype=64");
                    return;
                }

                if (e.Url.OriginalString.StartsWith("http://my.naver.com/"))
                {
                    this.browserBehind.Visible = false;
                    this.TIP_LABEL.Text        = "로그인 데이터를 가져오고 있습니다 ...";

                    e.Cancel = true;

                    if (Utility.GetUriCookieContainer(e.Url).GetCookies(e.Url).Count > 0)
                    {
                        AutoLogin.SetAccountDataResult result = AutoLogin.SetAccountData(IDTemp, PWDTemp, IDTemp);

                        switch (result)
                        {
                        case AutoLogin.SetAccountDataResult.Success:
                            NotifyBox.Show(this, "자동 로그인 설정 완료", "자동 로그인 설정을 완료했습니다, 다음 로그인 시 부터 자동 로그인이 적용됩니다.", NotifyBoxType.OK, NotifyBoxIcon.Information);
                            this.Close( );
                            break;

                        case AutoLogin.SetAccountDataResult.FileCreateFailed:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 파일 접근 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            this.Close( );
                            break;

                        case AutoLogin.SetAccountDataResult.EncryptFailed:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 암호화 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            this.Close( );
                            break;

                        case AutoLogin.SetAccountDataResult.Unknown:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            this.Close( );
                            break;

                        default:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            this.Close( );
                            break;
                        }

                        return;
                    }
                    else
                    {
                        Utility.WriteErrorLog("CookieIsEmpty_AutoLoginSettingForm", Utility.LogSeverity.ERROR);
                        NotifyBox.Show(this, "오류", "죄송합니다, 로그인 데이터를 가져올 수 없었습니다, 다시 시도하세요.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                        this.Close( );
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(this, "오류", "죄송합니다, 로그인 데이터를 가져올 수 없었습니다, 다시 시도하세요.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                this.Close( );
            }
        }
Example #2
0
        private void browserBehind_Navigating(object sender, WebBrowserNavigatingEventArgs e)
        {
            try
            {
                System.Collections.Specialized.NameValueCollection query = System.Web.HttpUtility.ParseQueryString(e.Url.Query);

                if (query.Get("a") == "log.naver")                     // 위에 로고를 클릭함.
                {
                    e.Cancel = true;
                    this.browserBehind.Navigate("https://nid.naver.com/nidlogin.login?svctype=64");
                    return;
                }

                if (e.Url.OriginalString.StartsWith("http://my.naver.com/"))
                {
                    this.browserBehind.Visible = false;

                    e.Cancel = true;

                    CookieCollection collection = Utility.GetUriCookieContainer(e.Url).GetCookies(e.Url);

                    if (collection.Count > 0)
                    {
                        StringBuilder cookiesString = new StringBuilder( );

                        foreach (Cookie i in collection)
                        {
                            cookiesString.Append(i.Name + "=" + i.Value + "; ");
                        }

                        GlobalVar.COOKIES      = cookiesString.ToString( ).Substring(0, cookiesString.Length - 2);
                        GlobalVar.COOKIES_LIST = Utility.CookieParse(GlobalVar.COOKIES);

                        bool isValidAccount = NaverRequest.AccountPermissionCheck( );

                        if (isValidAccount)
                        {
                            if (Config.Get("AutoLoginRecommendNeed", "1") == "1")
                            {
                                if (NotifyBox.Show(this, "자동 로그인 설정 권장", IDTemp + " 계정 자동 로그인 설정을 하시겠습니까? 자동 로그인 설정을 하시면 다음부터는 아이디와 암호를 입력할 필요가 없습니다.\n\n단, 공공장소에서는 절대로 하지 마십시오, 메인 화면에서 설정 메뉴로 들어가 언제든지 자동 로그인 설정을 바꿀 수 있습니다.", NotifyBoxType.YesNo, NotifyBoxIcon.Information) == NotifyBoxResult.Yes)
                                {
                                    AutoLogin.SetAccountDataResult result = AutoLogin.SetAccountData(IDTemp, PWDTemp, IDTemp);

                                    switch (result)
                                    {
                                    case AutoLogin.SetAccountDataResult.Success:
                                        NotifyBox.Show(this, "자동 로그인 설정 완료", "자동 로그인 설정을 완료했습니다, 다음 로그인 시 부터 자동 로그인이 적용됩니다.", NotifyBoxType.OK, NotifyBoxIcon.Information);
                                        break;

                                    case AutoLogin.SetAccountDataResult.FileCreateFailed:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 파일 접근 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                        break;

                                    case AutoLogin.SetAccountDataResult.EncryptFailed:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 암호화 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                        break;

                                    case AutoLogin.SetAccountDataResult.Unknown:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                        break;

                                    default:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 설정을 하지 못했습니다, 알 수 없는 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                        break;
                                    }
                                }

                                Config.Set("AutoLoginRecommendNeed", "0");
                            }

                            this.Close( );
                        }
                        else
                        {
                            NotifyBox.Show(this, "오류", "죄송합니다, 귀하는 연애혁명 공식 팬카페 '카페혁명 우윳빛깔 232'의 스탭이 아닙니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            Application.Exit( );
                        }
                    }
                    else
                    {
                        Utility.WriteErrorLog("CookieIsEmpty", Utility.LogSeverity.ERROR);
                        NotifyBox.Show(this, "오류", "죄송합니다, 로그인 데이터를 가져올 수 없었습니다, 다시 시도하세요.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                        Application.Exit( );
                    }
                }
            }
            catch (Exception ex)
            {
                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                NotifyBox.Show(this, "오류", "죄송합니다, 로그인 데이터를 가져올 수 없었습니다, 다시 시도하세요.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                Application.Exit( );
            }
        }