Beispiel #1
0
 public void Synchronize()
 {
     SecuruStikMessageQueue.SendMessage_Checking_Begin();
     Synchronize_Local2DropBox(AppSetting.Path_Local_SecuruStikFolder);
     Synchronize_DropBox2Local(DropBoxController.DropBox_SecFolder);
     SecuruStikMessageQueue.SendMessage_Checking_End();
 }
 public void Receive()
 {
     while (true)
     {
         try
         {
             int    packetSize  = this.br.ReadInt32();
             byte[] packetBytes = this.br.ReadBytes(packetSize);
             DealReceivedData(packetBytes);
             if (this.IsInited == false)
             {
                 Supend_ReceiveThread();
             }
         }
         catch (System.Exception ex)
         {
             if (this.IsLogin == true)
             {
                 SecuruStikMessageQueue.SendMEssage_Disconnect();
                 this.IsInited = false;
                 this.IsLogin  = false;
                 Supend_ReceiveThread();
             }
             else
             {
                 break;
             }
         }
     }
 }
Beispiel #3
0
        private void Share()
        {
            StringBuilder sb = new StringBuilder();

            foreach (String SelectedItemPath in SelectedItemPaths)
            {
                sb.AppendFormat("{0}|", SelectedItemPath);
            }
            SecuruStikMessageQueue.SendMessage_Share(sb.ToString());
        }
Beispiel #4
0
        static void Main(String[] args)
        {
            if ((args != null) && (args.Length > 0))
            {
                String filePath = String.Empty;
                for (int i = 0; i < args.Length; i++)
                {
                    filePath += Path.GetFullPath(args[i]) + SecuruStikMessageType.SplitChar;
                }

                SecuruStikMessageQueue.SendMessage_Download(filePath);
            }
        }
Beispiel #5
0
 public void CopyAsync(String copyRef, String downloadPath)
 {
     this.client.CopyFromCopyRefAsync(copyRef, downloadPath,
                                      (response) =>
     {
     },
                                      (error) =>
     {
         PreKeyring.SharingFile_Delete(copyRef);
         SecuruStikMessageQueue.SendMessage_Download_Failed();
     }
                                      );
 }
Beispiel #6
0
 private void Download(String fullPath)
 {
     Byte[] siBytes = File.ReadAllBytes(fullPath);
     SecuruStik.Protocal.SharingInfo si = SerializeHelper.DeSerialize(siBytes) as SecuruStik.Protocal.SharingInfo;
     if (si != null)
     {
         this.DropBoxUser.DownloadSharingFile(si);
         Notify_Download_Begin(si.FileName, si.ID_TO);
     }
     else
     {
         SecuruStikMessageQueue.SendMessage_Download_Failed();
     }
 }
Beispiel #7
0
 private void StartWork()
 {
     if (!this.IsBusy)
     {
         if (String.IsNullOrWhiteSpace(VelostiScsi.PubDrive))
         {
             SecuruStikMessageQueue.SendMessage_Notify_Eject();
             return;
         }
         SecuruStikMessageQueue.SendMessage_Sync_Begin();
         this.IsBusy = true;
         this.Worker.RunWorkerAsync();
     }
 }
Beispiel #8
0
 private void WaitForPlugin()
 {
     while (true)
     {
         if (VelostiScsi.IsPlugin_CurrDrive == false)
         {
             Process.GetCurrentProcess().Kill();
         }
         else if (VelostiScsi.IsPlugin_PubDrive == true)
         {
             SecuruStikMessageQueue.SendMessage_Notify_Plug();
             this.StartWork();
             break;
         }
     }
 }
Beispiel #9
0
        private void ShareWorker_DoWork(object sender, DoWorkEventArgs e)
        {
            while (this.ShareTaskWaitingList.Count != 0)
            {
                for (int i = this.ShareTaskWaitingList.Count - 1; i >= 0; i--)
                {
                    ShareTaskUnit worker = this.ShareTaskWaitingList[i];
                    PublicKey     pubkey = worker.PK;
                    //Key1
                    PRE_KEY key = ProxyReEncryption.GenKey(
                        PreKeyring.UserKey.PK1,
                        PreKeyring.UserKey.PK2,
                        PreKeyring.UserKey.SK1,
                        PreKeyring.UserKey.SK2);

                    //Key_pk2
                    PRE_PK key2_pk = ProxyReEncryption.GenPK(pubkey.PK1, pubkey.PK2);

                    //ReKey
                    PRE_Cipher reKey = ProxyReEncryption.KeyEncrypt(key, key2_pk, worker.Key);

                    String cpyRef = this.DropboxController.GetCopyRef(
                        this.DropboxController.SecuruStikFolder2RemoteDropboxPath(worker.FilePath));
                    if (String.IsNullOrEmpty(cpyRef))
                    {
                        continue;//获取copyref失败处理
                    }
                    else
                    {
                        worker.CpyRef = cpyRef;
                    }

                    SecuruStik.Protocal.SharingInfo si = new SecuruStik.Protocal.SharingInfo(
                        this.Email,
                        pubkey.ID,
                        Path.GetFileName(worker.FilePath),
                        worker.CpyRef,
                        reKey.E, reKey.F, reKey.U, reKey.W);

                    Request r = new Request(MessageType.Request_SetSharingInfo, this.DropboxController.Email, si);
                    this.ProxyServerController.Send(r);
                    this.ShareTaskWaitingList.Remove(worker);
                    SecuruStikMessageQueue.SendMessage_Share_End(Path.GetFileName(worker.FilePath), worker.ID_TO);
                }
            }
        }
Beispiel #10
0
 private void timer_Elapsed()
 {
     while (true)
     {
         if (VelostiScsi.IsPlugin_CurrDrive == false)
         {
             Process.GetCurrentProcess().Kill();
         }
         else if (VelostiScsi.IsPlugin_PubDrive == false)
         {
             SecuruStikMessageQueue.SendMessage_Notify_Eject();
             WaitForPlugin();
             break;
         }
         Thread.Sleep(1000);
     }
 }
Beispiel #11
0
        // TODO: this is displaying a Form which is not so good for unit testing or anything
        public Boolean Login()
        {
            try
            {
                //Check prekeyring.xml to see if the Dropbox credential exists.
                SecuruStik.DB.AccessToken at = PreKeyring.AccessToken;
                //If not,pop up a login window asking the user to enter his/her account && password
                if (at == null)
                {
                    this.client = new DropNet.DropNetClient(AppSetting.apiKey, AppSetting.appSecret);
                    this.client.GetToken();

                    //Ask user to enter DropBox account and password
                    SecuruStikMessageQueue.SendMessage_Splash_Hiden();
                    AuthorizeForm af = new AuthorizeForm(this.AuthorizeUrl);
                    af.ShowDialog();

                    if (af.DialogResult == DialogResult.OK)
                    {
                        return(this.GetAccessToken());
                    }
                    else if (af.DialogResult == DialogResult.Cancel)
                    {
                        return(false);
                    }
                }
                else
                {
                    this.client = new DropNet.DropNetClient(
                        AppSetting.apiKey,
                        AppSetting.appSecret,
                        at.UserToken, at.UserSecret, null);
                }
            } catch (System.Exception ex)
            {
                throw new SecuruStikException(
                          SecuruStikExceptionType.DropBoxControl_Login,
                          "Failed to Login the dropbox",
                          ex);
            }
            return(true);
        }
Beispiel #12
0
 private void Initialization()
 {
     //Do the initial work
     try
     {
         DropBoxUser = new DBox_User();
         this.BeginInvoke(new MethodInvoker(this.Close));
     }
     catch (System.Exception ex)
     {
         SecuruStikMessageQueue.SendMessage_Splash_Hiden();
         MessageBox.Show(
             new Form {
             TopMost = true, StartPosition = FormStartPosition.CenterScreen
         },
             ex.Message, "Sorry, our program meets some mistakes...",
             System.Windows.Forms.MessageBoxButtons.OK,
             System.Windows.Forms.MessageBoxIcon.Error);
         Process.GetCurrentProcess().Kill();
     }
 }
 private void DealReceivePK(RequestContent ResponseContent)
 {
     SecuruStik.Protocal.PublicKey receivepk = ResponseContent as SecuruStik.Protocal.PublicKey;
     if (receivepk != null)
     {
         PublicKeyUnit pku = PKList[receivepk.ID];
         if (pku == null)
         {
             this.PKList.Add(new PublicKeyUnit(receivepk.ID, receivepk));
         }
         else
         {
             PublicKey pk = pku.PK;
             if (pk == null || pk.PK1 != receivepk.PK1 || pk.PK2 != receivepk.PK2)
             {
                 pku.PK = receivepk;
             }
         }
         SecuruStikMessageQueue.SendMessage_ReceivePK(pku.ID, pku.PK.PK1, pku.PK.PK2);
     }
     return;
 }
Beispiel #14
0
 private void TaskWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
 {
     this.IsBusy = false;
     SecuruStikMessageQueue.SendMessage_Sync_End();
 }