Ejemplo n.º 1
0
 private void LoginWindow_Shown(object sender, EventArgs e)
 {
     Settings.Default.Upgrade();
     if (Settings.Default.TryAutoLogin)
     {
         this.submitBtn_Click(null, null);
         return;
     }
     string[] commandLineArgs = Environment.GetCommandLineArgs();
     if (commandLineArgs.Length <= 1)
     {
         return;
     }
     if (this.LicenceKeyBox.Text.Length > 0)
     {
         if (commandLineArgs[1] == "-autologin")
         {
             this.submitBtn_Click(null, null);
             return;
         }
         AutoLogin autoLogin = new AutoLogin(1.5f);
         if (autoLogin.ShowDialog(this) == DialogResult.OK)
         {
             this.submitBtn_Click(null, null);
         }
     }
 }
        void DownloadRepository(object state)
        {
            DownloadRepositoryParameters parameters = (DownloadRepositoryParameters)state;

            try
            {
                IPlasticWebRestApi restApi           = new PlasticWebRestApi();
                string             defaultCloudAlias = restApi.GetDefaultCloudAlias();

                RepositorySpec repSpec = BuildRepSpec(
                    parameters.CloudRepository,
                    parameters.CloudOrganization,
                    defaultCloudAlias);

                // we just download a cloud project,
                // so let's assume we're going to use Cloud Edition
                SetupUnityEditionToken.CreateCloudEditionTokenIfNeeded();

                if (!ClientConfig.IsConfigured())
                {
                    AutoConfigClientConf.FromUnityAccessToken(
                        parameters.AccessToken,
                        repSpec,
                        parameters.ProjectPath);
                }

                if (WorkspaceExists(parameters.ProjectPath))
                {
                    // each domain reload, the package is reloaded.
                    // way need to check if we already downloaded it
                    return;
                }

                mDisplayProgress = true;

                WorkspaceInfo wkInfo = CreateWorkspace(
                    repSpec, parameters.ProjectPath);

                mLog.DebugFormat("Created workspace {0} on {1}",
                                 wkInfo.Name,
                                 wkInfo.ClientPath);

                AutoLogin autoLogin = new AutoLogin();
                autoLogin.ExchangeTokens(parameters.AccessToken);

                CloudEditionWelcomeWindow.JoinOrganization(parameters.CloudOrganization, AutoLogin.sAccessToken, AutoLogin.sUserName);

                ClientConfigData clientConfigData = ClientConfig.Get().GetClientConfigData();
                clientConfigData.WorkspaceServer = parameters.CloudOrganization;
                ClientConfig.Get().Save(clientConfigData);

                Plastic.API.Update(
                    wkInfo.ClientPath,
                    UpdateFlags.None,
                    null,
                    mUpdateNotifier);
            }
            catch (Exception ex)
            {
                LogException(ex);

                UnityEngine.Debug.LogErrorFormat(
                    PlasticLocalization.GetString(PlasticLocalization.Name.ErrorDownloadingCloudProject),
                    ex.Message);

                mOperationFailed = true;
            }
            finally
            {
                mOperationFinished = true;
            }
        }
Ejemplo n.º 3
0
        private void AutoLoginManagerForm_Load(object sender, EventArgs e)
        {
            Animation.UI.FadeIn(this);

            string accountString = null;

            AutoLogin.GetAccountDataResult result = AutoLogin.GetAccountData(out accountString);

            switch (result)
            {
            case AutoLogin.GetAccountDataResult.Success:
                if (!string.IsNullOrEmpty(accountString))
                {
                    string[] dataTable = accountString.Trim( ).Split('\n');

                    if (dataTable.Length == 3)
                    {
                        this.USERID_VALUE.Text = dataTable[0];
                        this.PWD_VALUE.Text    = new string( '*', dataTable[1].Length * new Random(DateTime.Now.Second).Next(2, 4));

                        if (System.IO.File.Exists(GlobalVar.APP_DIR + @"\data\profileImage.jpg"))
                        {
                            try
                            {
                                this.PROFILE_IMAGE.BackgroundImage = Image.FromFile(GlobalVar.APP_DIR + @"\data\profileImage.jpg");
                            }
                            catch (Exception ex)
                            {
                                Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                                NotifyBox.Show(this, "오류", "죄송합니다, 계정 프로필 사진을 불러올 수 없습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            }
                        }
                    }
                    else
                    {
                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 데이터 구조 문제가 발생했습니다, 설정이 초기화되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                        AutoLogin.DeleteAccountData( );
                        this.Close( );
                    }
                }
                else
                {
                    NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 데이터 구조 문제가 발생했습니다, 설정이 초기화되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                    AutoLogin.DeleteAccountData( );
                    this.Close( );
                }

                break;

            case AutoLogin.GetAccountDataResult.FileNotFound:
                NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 파일을 찾을 수 없습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                this.Close( );
                break;

            case AutoLogin.GetAccountDataResult.DecryptFailed:
                NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 복호화 오류가 발생했습니다, 설정이 초기화되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                AutoLogin.DeleteAccountData( );
                this.Close( );
                break;

            case AutoLogin.GetAccountDataResult.Unknown:
                NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 알 수 없는 오류가 발생했습니다, 설정이 초기화되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                AutoLogin.DeleteAccountData( );
                this.Close( );
                break;

            default:
                NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 알 수 없는 오류가 발생했습니다, 설정이 초기화되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                AutoLogin.DeleteAccountData( );
                this.Close( );
                break;
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Packets handled in this function are 'internal' and cannot be overriden.
        /// </summary>
        internal bool HandlePacket(PacketEventArgs e)
        {
            if (IsCaptcha)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    FastPing = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DUMMY:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN:
                    AutoLogin login = (AutoLogin)e.Packet;
                    AresCommands.HandleAutoLogin(server, this, login.Sha1Password);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;
                    FinishCaptcha(pub.Message);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;
                    FinishCaptcha(emote.Message);
                    return(true);

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    LastUpdate = DateTime.Now;
                    NodeIp     = update.NodeIp;
                    NodePort   = update.NodePort;
                    return(true);

                default:
                    break;
                }
                return(false);
            }
            else if (LoggedIn)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    FastPing = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DUMMY:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;

                    if (AresCommands.HandlePreCommand(server, this, pub.Message))
                    {
                        return(true);
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }
                    break;

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;

                    if (AresCommands.HandlePreCommand(server, this, emote.Message))
                    {
                        return(true);
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }
                    break;

                case AresId.MSG_CHAT_CLIENT_COMMAND:
                    Command cmd = (Command)e.Packet;
                    if (AresCommands.HandleCommand(server, this, cmd.Message))
                    {
                        return(true);
                    }
                    break;

                case AresId.MSG_CHAT_CLIENT_PVT:
                    Private pvt = (Private)e.Packet;

                    if (Muzzled && !server.Config.MuzzledPMs)
                    {
                        pvt.Message = "[" + Strings.AreMuzzled + "]";
                        SendPacket(pvt);

                        return(true);
                    }

                    break;

                case AresId.MSG_CHAT_CLIENT_AUTHREGISTER: {
                    AuthRegister reg = (AuthRegister)e.Packet;
                    AresCommands.HandleRegister(server, this, reg.Password);
                    return(true);
                }

                case AresId.MSG_CHAT_CLIENT_AUTHLOGIN: {
                    AuthLogin login = (AuthLogin)e.Packet;
                    AresCommands.HandleLogin(server, this, login.Password);
                    return(true);
                }

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN: {
                    AutoLogin login = (AutoLogin)e.Packet;
                    AresCommands.HandleAutoLogin(server, this, login.Sha1Password);
                    return(true);
                }

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_IGNORELIST:
                    Ignored ignore = (Ignored)e.Packet;
                    if (ignore.Ignore)
                    {
                        lock (Ignored) {
                            if (!Ignored.Contains(ignore.Username))
                            {
                                Ignored.Add(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Ignored, ignore.Username));
                            }
                        }
                    }
                    else
                    {
                        lock (Ignored) {
                            if (Ignored.Contains(ignore.Username))
                            {
                                Ignored.Remove(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Unignored, ignore.Username));
                            }
                        }
                    }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    LastUpdate = DateTime.Now;
                    NodeIp     = update.NodeIp;
                    NodePort   = update.NodePort;
                    server.SendPacket((s) =>
                                      s.Vroom == Vroom &&
                                      s.CanSee(this),
                                      new ServerUpdate(this));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_DIRCHATPUSH:
                    ClientDirectPush push = (ClientDirectPush)e.Packet;

                    if (Encoding.UTF8.GetByteCount(push.Username) < 2)
                    {
                        SendPacket(new DirectPushError(4));
                        return(true);
                    }

                    if (push.TextSync.Length < 16)
                    {
                        SendPacket(new DirectPushError(3));
                        return(true);
                    }

                    IClient target = server.FindUser(s => s.Name == push.Username);

                    if (target == null)
                    {
                        SendPacket(new DirectPushError(1));
                        return(true);
                    }

                    if (target.Ignored.Contains(Name))
                    {
                        SendPacket(new DirectPushError(2));
                        return(true);
                    }

                    SendPacket(new DirectPushError(0));
                    server.SendPacket(target, new ServerDirectPush(this, push));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_BROWSE:
                    SendPacket(new BrowseError(((Browse)e.Packet).BrowseId));
                    return(true);

                case AresId.MSG_CHAT_CLIENT_SEARCH:
                    SendPacket(new SearchEnd(((Search)e.Packet).SearchId));
                    return(true);

                case AresId.MSG_CHAT_CLIENTCOMPRESSED: {
                    Compressed packet  = (Compressed)e.Packet;
                    byte[]     payload = Zlib.Decompress(packet.Data);

                    var reader = new PacketReader(payload)
                    {
                        Position = 0L
                    };

                    while (reader.Remaining >= 3)
                    {
                        ushort count = reader.ReadUInt16();
                        byte   id    = reader.ReadByte();

                        IPacket msg = Socket.Formatter.Unformat(id, reader.ReadBytes(count));
                        OnPacketReceived(Socket, new PacketEventArgs(msg, WebSocketMessageType.Binary, 0));
                    }
                    break;
                }

                default:
                    break;
                }

                return(false);//wasn't handled
            }
            else
            {
                //not captcha, not logged, error?
                Logging.Info("AresClient", "Client {0} sent {1} before logging in.", this.ExternalIp, e.Packet.Id);
                return(true);
            }
        }
Ejemplo n.º 5
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( );
            }
        }
Ejemplo n.º 6
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( );
            }
        }
Ejemplo n.º 7
0
        private void NaverLoginForm_Load(object sender, EventArgs e)
        {
            this.AUTOLOGIN_TITLE.Parent = BACKGROUND_SPLASH;
            this.AUTOLOGIN_DESC.Parent  = BACKGROUND_SPLASH;
            this.browserBehind.Visible  = false;

            Task.Factory.StartNew(() =>
            {
                if (Utility.IsInternetConnected( ))
                {
                    if (AutoLogin.IsEnabled( ))
                    {
                        SetMode(true);
                        SetMessage("계정 자동 로그인 정보를 불러오는 중 ");

                        string accountString = null;
                        AutoLogin.GetAccountDataResult result = AutoLogin.GetAccountData(out accountString);

                        switch (result)
                        {
                        case AutoLogin.GetAccountDataResult.Success:
                            if (!string.IsNullOrEmpty(accountString))
                            {
                                string[] dataTable = accountString.Trim( ).Split('\n');

                                if (dataTable.Length == 3)
                                {
                                    if (this.InvokeRequired)
                                    {
                                        this.Invoke(new Action(() => this.AUTOLOGIN_TITLE.Text = dataTable[2].Trim( )));
                                    }
                                    else
                                    {
                                        this.AUTOLOGIN_TITLE.Text = dataTable[2].Trim( );
                                    }

                                    SetMessage("자동 로그인을 시도하고 있습니다, 잠시만.. 기다려주세요 ");

                                    //Thread.Sleep( 1000 );

                                    CookieCollection collection;
                                    NaverRequest.NaverLoginResult result2 = NaverRequest.NaverAccountLogin(dataTable[0], dataTable[1], out collection);

                                    switch (result2)
                                    {
                                    case NaverRequest.NaverLoginResult.Success:
                                        StringBuilder sb = new StringBuilder( );

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

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

                                        bool isValidAccount = NaverRequest.AccountPermissionCheck( );

                                        if (isValidAccount)
                                        {
                                            SetMessage("계정 로그인을 완료했습니다.", true);

                                            Thread.Sleep(500);

                                            if (this.InvokeRequired)
                                            {
                                                this.Invoke(new Action(() => this.Close( )));
                                            }
                                            else
                                            {
                                                this.Close( );
                                            }

                                            break;
                                        }
                                        else
                                        {
                                            NotifyBox.Show(this, "오류", "죄송합니다, 해당 계정은 연애혁명 공식 팬카페 '카페혁명 우윳빛깔 232'의 스탭이 아닙니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                            AutoLogin.DeleteAccountData( );
                                            Application.Exit( );

                                            return;
                                        }

                                    case NaverRequest.NaverLoginResult.ChptchaRequired:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인에 실패했습니다, 자동 입력 방지 문자를 입력해야 합니다.", NotifyBoxType.OK, NotifyBoxIcon.Warning);
                                        SetMode(false);
                                        break;

                                    case NaverRequest.NaverLoginResult.IDorPWDError:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인에 실패했습니다, 아이디 또는 비밀번호가 올바르지 않습니다\n자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Warning);
                                        AutoLogin.DeleteAccountData( );

                                        SetMode(false);

                                        break;

                                    case NaverRequest.NaverLoginResult.SecurityBlocked:
                                        Utility.OpenWebPage("https://nid.naver.com/user2/help/myInfo.nhn?m=viewSecurity&menu=security", this);
                                        NotifyBox.Show(this, "알림", "죄송합니다, 자동 로그인에 실패했습니다\n자동 로그인을 사용하시려면 네이버 계정 보안 설정에서 '로그인 차단 설정' 또는 '새로운 기기 로그인 알림 설정'을 해제해주세요.", NotifyBoxType.OK, NotifyBoxIcon.Information);

                                        SetMode(false);

                                        break;

                                    case NaverRequest.NaverLoginResult.RequestError:
                                        NotifyBox.Show(this, "오류", "죄송합니다, 로그인에 실패했습니다, 서버 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);

                                        SetMode(false);

                                        break;
                                    }
                                }
                                else
                                {
                                    NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 데이터 구조 문제가 발생했습니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                    AutoLogin.DeleteAccountData( );

                                    SetMode(false);
                                }
                            }
                            else
                            {
                                NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 데이터 구조 문제가 발생했습니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                                AutoLogin.DeleteAccountData( );

                                SetMode(false);
                            }

                            break;

                        case AutoLogin.GetAccountDataResult.FileNotFound:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 파일을 찾을 수 없습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);

                            SetMode(false);

                            break;

                        case AutoLogin.GetAccountDataResult.DecryptFailed:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 복호화 오류가 발생했습니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            AutoLogin.DeleteAccountData( );

                            SetMode(false);

                            break;

                        case AutoLogin.GetAccountDataResult.Unknown:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 알 수 없는 오류가 발생했습니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            AutoLogin.DeleteAccountData( );

                            SetMode(false);
                            break;

                        default:
                            NotifyBox.Show(this, "오류", "죄송합니다, 자동 로그인 데이터를 불러오지 못했습니다, 알 수 없는 오류가 발생했습니다, 자동 로그인이 해제되었습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                            AutoLogin.DeleteAccountData( );

                            SetMode(false);

                            break;
                        }
                    }
                    else
                    {
                        SetMode(false);
                    }
                }
                else
                {
                    NotifyBox.Show(this, "네트워크 오프라인", "죄송합니다, 이 컴퓨터는 네트워크에 연결되지 않았습니다, 우윳빛깔 카페스탭은 온라인 상태에서만 사용하실 수 있습니다.", NotifyBoxType.OK, NotifyBoxIcon.Warning);
                    Application.Exit( );
                }
            });
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Packets handled in this function are 'internal' cannot be overriden.
        /// </summary>
        internal bool HandlePacket(PacketEventArgs e)
        {
            if (IsCaptcha)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    break;

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN:
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                    break;

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;
                    FinishCaptcha(pub.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;
                    FinishCaptcha(emote.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    SharedFile addfile = (SharedFile)e.Packet;

                    if (server.PluginManager.OnFileReceived(this, addfile))
                    {
                        lock (files) files.Add(addfile);
                    }

                    break;

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = TimeBank.CurrentTime;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    Region   = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;

                    break;
                }

                return(true); //don't handle any other packets yet
            }
            else if (LoggedIn)
            {
                switch ((AresId)e.Packet.Id)
                {
                case AresId.MSG_CHAT_CLIENT_FASTPING:
                    fastping = true;
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DUMMY:
                    return(true);

                case AresId.MSG_CHAT_CLIENT_PUBLIC:
                    ClientPublic pub = (ClientPublic)e.Packet;

                    if (!String.IsNullOrEmpty(pub.Message))
                    {
                        if (pub.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, pub.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_EMOTE:
                    ClientEmote emote = (ClientEmote)e.Packet;

                    if (!String.IsNullOrEmpty(emote.Message))
                    {
                        if (emote.Message.StartsWith("#") && Commands.HandlePreCommand(server, this, emote.Message.Substring(1)))
                        {
                            return(true);
                        }
                    }

                    if (Muzzled)
                    {
                        server.SendAnnounce(this, Strings.AreMuzzled);
                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_COMMAND:
                    Command cmd = (Command)e.Packet;
                    Commands.HandlePreCommand(server, this, cmd.Message);
                    break;

                case AresId.MSG_CHAT_CLIENT_PVT:
                    Private pvt = (Private)e.Packet;

                    if (Muzzled && !server.Config.MuzzledPMs)
                    {
                        pvt.Message = "[" + Strings.AreMuzzled + "]";
                        server.SendPacket(this, pvt);

                        return(true);
                    }

                    return(false);

                case AresId.MSG_CHAT_CLIENT_AUTHREGISTER: {
                    AuthRegister reg = (AuthRegister)e.Packet;
                    Commands.HandleRegister(server, this, reg.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTHLOGIN: {
                    AuthLogin login = (AuthLogin)e.Packet;
                    Commands.HandleLogin(server, this, login.Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_AUTOLOGIN: {
                    AutoLogin login = (AutoLogin)e.Packet;
                    Commands.HandleAutoLogin(server, this, login.Sha1Password);
                }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_ADDSHARE:
                    SharedFile addfile = (SharedFile)e.Packet;

                    if (server.PluginManager.OnFileReceived(this, addfile))
                    {
                        lock (files) files.Add(addfile);
                    }

                    return(true);

                case AresId.MSG_CHAT_CLIENT_IGNORELIST:
                    Ignored ignore = (Ignored)e.Packet;

                    if (ignore.Ignore)
                    {
                        lock (ignored) {
                            if (!ignored.Contains(ignore.Username))
                            {
                                ignored.Add(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Ignored, ignore.Username));
                            }
                        }
                    }
                    else
                    {
                        lock (ignored) {
                            if (ignored.Contains(ignore.Username))
                            {
                                ignored.Remove(ignore.Username);
                                server.SendAnnounce(this, String.Format(Strings.Unignored, ignore.Username));
                            }
                        }
                    }
                    return(true);

                case AresId.MSG_CHAT_CLIENT_UPDATE_STATUS:
                    ClientUpdate update = (ClientUpdate)e.Packet;

                    lastupdate = TimeBank.CurrentTime;

                    NodeIp   = update.NodeIp;
                    NodePort = update.NodePort;
                    Age      = (update.Age != 0) ? update.Age : Age;
                    Gender   = (update.Gender != 0) ? update.Gender : Gender;
                    Country  = (update.Country != 0) ? update.Country : Country;
                    Region   = !String.IsNullOrEmpty(update.Region) ? update.Region : Region;

                    server.SendPacket((s) => s.Vroom == Vroom, new ServerUpdate(this));
                    return(true);

                case AresId.MSG_CHAT_CLIENT_DIRCHATPUSH:
                    ClientDirectPush push = (ClientDirectPush)e.Packet;

                    if (Encoding.UTF8.GetByteCount(push.Username) < 2)
                    {
                        server.SendPacket(this, new DirectPushError(4));
                        return(true);
                    }

                    if (push.TextSync.Length < 16)
                    {
                        server.SendPacket(this, new DirectPushError(3));
                        return(true);
                    }

                    IClient target = server.FindUser(s => s.Name == push.Username);

                    if (target == null)
                    {
                        server.SendPacket(this, new DirectPushError(1));
                        return(true);
                    }

                    if (target.Ignored.Contains(Name))
                    {
                        server.SendPacket(this, new DirectPushError(2));
                        return(true);
                    }

                    server.SendPacket(this, new DirectPushError(0));
                    server.SendPacket(target, new ServerDirectPush(this, push));

                    return(true);

                case AresId.MSG_CHAT_CLIENT_BROWSE:
                    Browse browse = (Browse)e.Packet;

                    browse.Type = (byte)((browse.Type == 0) ? (byte)255 : browse.Type);
                    browse.Type = (byte)((browse.Type == 8) ? (byte)0 : browse.Type);

                    IClient browse_target = server.FindUser(s => s.Vroom == Vroom && s.Name == browse.Username);

                    if (browse_target == null)
                    {
                        return(true);
                    }

                    else if (browse_target.Files.Count == 0)
                    {
                        server.SendPacket(this, new BrowseError(browse.BrowseId));
                    }

                    else
                    {
                        server.SendPacket(this, new BrowseStart(browse.BrowseId, (ushort)browse_target.Files.Count));

                        foreach (var file in browse_target.Files)
                        {
                            if (browse.Type == 255 || browse.Type == file.Type)
                            {
                                server.SendPacket(this, new BrowseItem(browse.BrowseId, file));
                            }
                        }

                        server.SendPacket(this, new BrowseEnd(browse.BrowseId));
                    }

                    return(true);

                case AresId.MSG_CHAT_CLIENT_SEARCH:
                    Search search = (Search)e.Packet;

                    search.Type = (byte)((search.Type == 0) ? (byte)255 : search.Type);
                    search.Type = (byte)((search.Type == 8) ? (byte)0 : search.Type);

                    foreach (var user in server.Users)
                    {
                        if (user != this && user.Vroom == Vroom)
                        {
                            foreach (var file in user.Files)
                            {
                                if (file.SearchWords.ContainsAny(search.SearchWords.Split(new char[] { '\0' }, StringSplitOptions.RemoveEmptyEntries)))
                                {
                                    server.SendPacket(this, new SearchHit(search.SearchId, user, file));
                                }
                            }
                        }
                    }

                    server.SendPacket(this, new SearchEnd(search.SearchId));
                    return(true);
                }

                return(false);//wasn't handled
            }
            else
            {
                return(true);//not captcha, not logged, error
            }
        }
Ejemplo n.º 9
0
        private bool NaverAccountInitialize( )
        {
            NaverAccountInformation?         accountInformation = NaverRequest.AccountRequest( );
            Action <NaverAccountInformation> callBack           = ( NaverAccountInformation info ) =>
            {
                GlobalVar.NAVER_USER_ID = info.email;
                AutoLogin.ModifyAccountDataNickName(info.nickName);

                if (info.iconURL != "N")                   // 프로필 이미지가 설정되지 않으면 이미지 URL 이 N임
                {
                    try
                    {
                        if (!Directory.Exists(GlobalVar.DATA_DIR))
                        {
                            Directory.CreateDirectory(GlobalVar.DATA_DIR);
                        }

                        MemoryStream profileImageX80 = Utility.URLFileToMemoryStream(info.iconURL.Replace("?type=s160", "?type=s80"));
                        //MemoryStream profileImageX2 = Utility.URLFileToMemoryStream( info.iconURL );

                        if (profileImageX80 != null)
                        {
                            this.NAVER_ICON_IMAGE.BackgroundImage = new Bitmap(profileImageX80);
                        }
                        else
                        {
                            Utility.WriteErrorLog("NaverProfileImageX80LoadFailed", Utility.LogSeverity.ERROR);
                            NotifyBox.Show(this, "오류", "죄송합니다, 계정 프로필을 불러오는 중 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                        }

                        byte[] profileImageX160 = Utility.URLFileToByteArray(info.iconURL);

                        if (profileImageX160.Length > 0)
                        {
                            File.WriteAllBytes(GlobalVar.PROFILE_TEMP_DIR, profileImageX160);
                        }
                        else
                        {
                            Utility.WriteErrorLog("NaverProfileImageX160LoadFailed", Utility.LogSeverity.ERROR);
                            NotifyBox.Show(this, "오류", "죄송합니다, 계정 프로필을 불러오는 중 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                        }
                    }
                    catch (Exception ex)
                    {
                        Utility.WriteErrorLog(ex.Message, Utility.LogSeverity.EXCEPTION);
                        NotifyBox.Show(this, "오류", "죄송합니다, 계정 프로필을 불러오는 중 오류가 발생했습니다.", NotifyBoxType.OK, NotifyBoxIcon.Error);
                    }
                }
            };

            if (accountInformation.HasValue)
            {
                if (this.InvokeRequired)
                {
                    this.Invoke(new Action(() => callBack(accountInformation.Value)));
                }
                else
                {
                    callBack(accountInformation.Value);
                }

                return(true);
            }

            return(false);
        }