Exemplo n.º 1
0
        private void GetSetText(int id)
        {
            UserCredentialsStore store = UserCredentialsStore.GetInstance();

            if (store.Valid)
            {
                Random rand = new Random();
                int    r    = rand.Next();
                CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
                CodinggainClipboardService.EncryptionData           enData          = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                CodinggainClipboardService.ScratchDataInfo          data            = remoteClipboard.getScratchData(store.Username, store.getPassword(r), id, enData.access_key_id, r);
                if (data != null)
                {
                    if (data.containsdata)
                    {
                        currentContent = data.content;
                        string title = data.title;
                        if (title == null)
                        {
                            title = "";
                        }
                        setScratchText(currentContent, title);
                    }
                }
            }
        }
Exemplo n.º 2
0
        private void LoadButton_Click(object sender, EventArgs e)
        {
            DownloadClipboard upload = new DownloadClipboard();

            if (upload.ShowDialog() == DialogResult.OK)
            {
                try
                {
                    Random rand = new Random();
                    int    r    = rand.Next();
                    UserCredentialsStore store = UserCredentialsStore.GetInstance();
                    CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
                    CodinggainClipboardService.EncryptionData           enData          = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                    CodinggainClipboardService.ReturnInterface          data            = remoteClipboard.getClipboardContent(store.Username, store.getPassword(r), upload.Fromdate, upload.Todate, enData.access_key_id, r);
                    if (data.success)
                    {
                        string str = Decode(data.content, (byte)enData.encrypt_key);
                        update(str);
                    }
                }
                catch (Exception ex)
                {
                }
            }
        }
Exemplo n.º 3
0
 private void searchDatabaseToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         SearchDatabase search = new SearchDatabase();
         if (search.ShowDialog() == DialogResult.OK)
         {
             string criteria            = search.Criteria;
             Random rand                = new Random();
             int    r                   = rand.Next();
             UserCredentialsStore store = UserCredentialsStore.GetInstance();
             CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
             CodinggainClipboardService.EncryptionData           enData          = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
             CodinggainClipboardService.ReturnInterface          content         = remoteClipboard.searchClipboard(store.Username, store.getPassword(r), criteria, enData.access_key_id, r, 0);
             if (content != null && content.success)
             {
                 string contents = "";
                 string errors   = "";
                 if (content.numberOfSegments > 1)
                 {
                     int segs = content.numberOfSegments;
                     for (int n = 0; n < segs; n++)
                     {
                         try
                         {
                             enData  = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                             content = remoteClipboard.searchClipboard(store.Username, store.getPassword(r), criteria, enData.access_key_id, r, n + 1);
                             if (content != null && content.success)
                             {
                                 contents += Decode(content.content, (byte)enData.encrypt_key);
                             }
                         }
                         catch (Exception ex)
                         {
                             errors += " : Errors!!";
                         }
                     }
                 }
                 else
                 {
                     contents = Decode(content.content, (byte)enData.encrypt_key);
                 }
                 DisplayText dis = new DisplayText(contents);
                 dis.SearchWord(criteria);
                 dis.updateTitle(errors);
                 dis.ShowDialog();
             }
             else
             {
                 DisplayText dis = new DisplayText("Did not return any results!");
                 dis.SearchWord(criteria);
                 dis.ShowDialog();
             }
         }
     }
     catch
     {
     }
 }
Exemplo n.º 4
0
        public static UserCredentialsStore GetInstance()
        {
            if (instance == null)
            {
                instance = new UserCredentialsStore();
            }

            return(instance);
        }
Exemplo n.º 5
0
        public void LoadScratchDates()
        {
            dateList.Clear();
            SelectComboBox.Items.Clear();
            CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
            if (remoteClipboard != null)
            {
                Random rand = new Random();
                int    r    = rand.Next();
                UserCredentialsStore store = UserCredentialsStore.GetInstance();
                if (store.Valid)
                {
                    SaveButton.Enabled = true;
                    CodinggainClipboardService.EncryptionData    enData = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                    CodinggainClipboardService.ScratchDataInfo[] dates  = remoteClipboard.getScratchDates(store.Username, store.getPassword(r), enData.access_key_id, r);

                    foreach (CodinggainClipboardService.ScratchDataInfo info in dates)
                    {
                        try
                        {
                            if (info.date != null)
                            {
                                DateListComboInfo dl = new DateListComboInfo();
                                dl.date = info.date;
                                if (info.title != null)
                                {
                                    dl.title = info.title;
                                }
                                dl.id = info.id;
                                dateList.Add(dl);
                                // ListViewItem item = new ListViewItem(info.date);
                                string tt = info.date;
                                if (info.title != null)
                                {
                                    tt += " " + info.title;
                                }
                                SelectComboBox.Items.Add(info.date + " " + tt);
                            }
                        }
                        catch (Exception ex)
                        {
                        }
                    }

                    if (dates.Length > 0)
                    {
                        SelectComboBox.SelectedIndex = 0;
                        SelectComboBox.Text          = dates[0].date;
                    }
                }
            }
        }
Exemplo n.º 6
0
        private void userCredentialsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            UserCredentials usercred = new UserCredentials();

            if (usercred.ShowDialog() == DialogResult.OK)
            {
                UserCredentialsStore store = UserCredentialsStore.GetInstance();
                if (store.Valid)
                {
                    SendButton.Enabled = true;
                    uploadScheduleToolStripMenuItem.Enabled = true;
                }
            }
        }
Exemplo n.º 7
0
        private void SendButton_Click(object sender, EventArgs e)
        {
            string output = "";
            UserCredentialsStore store = UserCredentialsStore.GetInstance();

            lock (backupToServer)
            {
                if (!string.IsNullOrEmpty(backupToServer))
                {
                    sendtoServer(backupToServer);
                    backupToServer = "";
                }
            }
        }
Exemplo n.º 8
0
 private void Form1_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         _fileTimer_Tick(null, null);
         XmlSerializer        ser   = new XmlSerializer(typeof(User));
         UserCredentialsStore store = UserCredentialsStore.GetInstance();
         StreamWriter         file  = new StreamWriter("userinfo.dat");
         ser.Serialize(file, store.Credentials);
     }
     catch (Exception ex)
     {
     }
     lock (backupToServer)
     {
         sendtoServer(backupToServer);
     }
 }
Exemplo n.º 9
0
        private void sendData()
        {
            CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();

            if (!string.IsNullOrEmpty(ScratchPadTextBox.Text) && ScratchPadTextBox.Text != currentContent)
            {
                EncoderDecoder       encoder = new EncoderDecoder();
                Random               rand    = new Random();
                int                  r       = rand.Next();
                UserCredentialsStore store   = UserCredentialsStore.GetInstance();
                CodinggainClipboardService.EncryptionData enData = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                string str = encoder.Encode(ScratchPadTextBox.Text, (byte)enData.encrypt_key);
                currentContent = ScratchPadTextBox.Text;
                int id = remoteClipboard.putScratchPad(store.Username, store.getPassword(r), TitleTextBox.Text, str, ImportantCheckBox.Checked, false, enData.access_key_id, r, 0);
                if (ImportantCheckBox.Checked)
                {
                    ImportantCheckBox.Checked = false;
                }
                LoadScratchDates();
            }
        }
Exemplo n.º 10
0
        private bool sendtoServer(string text)
        {
            try
            {
                if (text.Length > MaxUploadSize)
                {
                    int    size  = text.Length;
                    string local = text;
                    text = local.Substring(0, MaxUploadSize);
                    string whatsleft = text.Substring(MaxUploadSize, size);
                    //  Invoke(new SendToServer(sendtoServer, new object[] { whatsleft }));
                }
                Random rand = new Random();
                int    r    = rand.Next();
                UserCredentialsStore store = UserCredentialsStore.GetInstance();
                CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
                CodinggainClipboardService.EncryptionData           enData          = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                if (enData.useable)
                {
                    string str = Encode(backupToServer, (byte)enData.encrypt_key);
                    if (!remoteClipboard.putClipboardContent(store.Username, store.getPassword(r), str, enData.access_key_id, r))
                    {
                        DifferenceTextBox.Text = "Unable to upload clip text!";
                    }
                }
                else
                {
                    DifferenceTextBox.Text = "Passwar not useable";
                }
                remoteClipboard.Close();
            }
            catch (Exception ex)
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 11
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     try
     {
         scratchPad.FormClosed += ScratchPad_FormClosed;
         scratchPad.Show();
         enabledToolStripMenuItem.Checked = true;
         if (File.Exists("userinfo.dat"))
         {
             XmlSerializer        ser   = new XmlSerializer(typeof(User));
             UserCredentialsStore store = UserCredentialsStore.GetInstance();
             Random       rand          = new Random();
             int          r             = rand.Next();
             StreamReader file          = new StreamReader("userinfo.dat");
             User         user          = (User)ser.Deserialize(file);
             store.Credentials = user;
             CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
             //ClipboardServiceTest.ClipboardInterfaceClient remoteClipboard = new ClipboardServiceTest.ClipboardInterfaceClient();
             store.Valid        = remoteClipboard.checkCredantials(store.Username, store.getPassword(r), r);
             SendButton.Enabled = store.Valid;
             uploadScheduleToolStripMenuItem.Enabled = store.Valid;
             if (store.Valid)
             {
                 MaxUploadSize        = remoteClipboard.getMaxSize();
                 uploadTimer.Interval = 60 * 1000 * 5;
                 uploadTimer.Start();
             }
             remoteClipboard.Close();
         }
         scratchPad.LoadScratchDates();
         scratchPad.intialise();
     }
     catch (Exception ex)
     {
     }
 }
Exemplo n.º 12
0
        void BackHaulThread()
        {
            Random rand = new Random();

            while (running)
            {
                try
                {
                    int r = rand.Next();
                    UserCredentialsStore store = UserCredentialsStore.GetInstance();
                    CodinggainClipboardService.ClipboardInterfaceClient remoteClipboard = new CodinggainClipboardService.ClipboardInterfaceClient();
                    CodinggainClipboardService.EncryptionData           enData          = remoteClipboard.getAccessRights(store.Username, store.getPassword(r), true, r);
                    String clip = remoteClipboard.checkForClip(store.Username, store.getPassword(r), enData.access_key_id, r);
                    if (!string.IsNullOrEmpty(clip))
                    {
                        update(clip);
                    }
                }
                catch
                {
                }
                System.Threading.Thread.Sleep(1000);
            }
        }