Exemplo n.º 1
0
 public MRequestUpdateAttributes(MegaUser user, MegaNode node) : base(user)
 {
     MegaNode.EncryptAttrs(node);
     encryptedAttributes = node.encryptedAttributes;
     n   = node.Id;
     key = node.NodeKey.EncryptedKey;
 }
Exemplo n.º 2
0
        public void query_with_or_on_child_document()
        {
            StoreOptions(_ =>
            {
                _.Schema.For <User>().AddSubClass <MegaUser>();
            });

            var megaUser1 = new MegaUser()
            {
                DisplayName = "Yann", RealName = "Yann Yann"
            };
            var megaUser2 = new MegaUser()
            {
                DisplayName = "Robin", RealName = "Robin Robin"
            };
            var megaUser3 = new MegaUser()
            {
                DisplayName = "Marten", RealName = "Marten Marten"
            };

            theStore.BulkInsert(new User[] { megaUser1, megaUser2, megaUser3 });

            using (var session = theStore.QuerySession())
            {
                session.Query <MegaUser>()
                .Where(_ => _.DisplayName == "Yann" || _.DisplayName == "Robin").OrderBy(x => x.DisplayName).Select(x => x.DisplayName)
                .ToList()
                .ShouldHaveTheSameElementsAs("Robin", "Yann");
            }
        }
Exemplo n.º 3
0
        public Form1()
        {
            InitializeComponent();

            System.Net.ServicePointManager.DefaultConnectionLimit = 50;
            notifyIcon1.Icon   = Properties.Resources.min;
            notifyIcon1.Click += notifyIcon1_MouseClick;

            if (!string.IsNullOrEmpty(Properties.Settings.Default.folderPath))
            {
                textBoxFolder.Text = Properties.Settings.Default.folderPath;
            }
            else
            {
                textBoxFolder.Text = Path.Combine(
                    Environment.GetEnvironmentVariable("USERPROFILE"),
                    "MegaDesktop");
            }

            auth = Mega.LoadAccount(GetUserKeyFilePath());
            if (auth != null)
            {
                textBoxEmail.Text    = auth.Email;
                textBoxPassword.Text = "password";
            }
        }
Exemplo n.º 4
0
 public NodeKeys(byte[] key, MegaUser user)
 {
     DecryptedKey = key;
     EncryptedKey = Crypto.Encrypt(user.masterKeyAlg, key);
     Keys         = new Dictionary <string, byte[]> {
         { user.Id, EncryptedKey }
     };
 }
Exemplo n.º 5
0
        public MRequestCompleteUpload(MegaUser user, MegaNode node) : base(user)
        {
            t = node.ParentId;
            n = new List <MegaNode> {
                node
            };
            this.user = user;

            Converters.Add(new NodeKeyConverter(user.masterKeyAlg, user));
        }
Exemplo n.º 6
0
 public MRequestGetSid(MegaUser user) : base(user)
 {
     Sid       = null;
     this.user = user.Id;
     passKey   = user.PassKey;
     if (user.Email != null)
     {
         this.user = user.Email.ToLower();
         uh        = user.GetHash();
     }
 }
Exemplo n.º 7
0
        public MRequestCreateAnon(MegaUser user)
            : base(user)
        {
            var ssc   = Crypto.RandomKey(16);
            var aes   = Crypto.CreateAes(user.PassKey);
            var e_ssc = Crypto.Encrypt(aes, ssc);

            ts = new byte[ssc.Length + e_ssc.Length];
            Array.Copy(ssc, ts, ssc.Length);
            Array.Copy(e_ssc, 0, ts, ssc.Length, e_ssc.Length);

            k = user.EncryptUserKey();
        }
Exemplo n.º 8
0
        public MRequestCreateFolder(MegaUser user, string folderName, string parentNode) : base(user)
        {
            this.user = user;
            t         = parentNode;
            var folder = new MegaNode
            {
                Id         = "xxxxxxxx",
                Type       = MegaNodeType.Folder,
                Attributes = new NodeAttributes {
                    Name = folderName
                },
                NodeKey = new NodeKeys(Crypto.RandomKey(16), user)
            };

            n.Add(folder);

            Converters.Add(new NodeKeyConverter(user.masterKeyAlg, user));
        }
Exemplo n.º 9
0
        // p - ?

        public MRequestGetDownloadUrl(MegaUser user, string nodeId) : base(user)
        {
            n = nodeId;
        }
Exemplo n.º 10
0
 public MRequestRemoveNode(MegaUser user, string nodeId) : base(user)
 {
     n = nodeId;
 }
Exemplo n.º 11
0
 public PollingTransport(MegaUser user) { this.user = user; }
Exemplo n.º 12
0
        private void buttonStart_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(textBoxEmail.Text) ||
                string.IsNullOrEmpty(textBoxPassword.Text) ||
                string.IsNullOrEmpty(textBoxFolder.Text)
                )
            {
                return;
            }
            buttonBrowse.Enabled  = false;
            textBoxFolder.Enabled = false;
            buttonStart.Enabled   = false;
            buttonExit.Enabled    = false;
            if (!Directory.Exists(textBoxFolder.Text))
            {
                Directory.CreateDirectory(textBoxFolder.Text);
                Properties.Settings.Default.FolderBeautified = false;
            }

            var needResync = false;

            if (Properties.Settings.Default.folderPath != textBoxFolder.Text)
            {
                needResync = true;
                Properties.Settings.Default.FolderBeautified = false;
            }

            Properties.Settings.Default.folderPath = textBoxFolder.Text;
            Properties.Settings.Default.Save();

            CheckFolderBeautified();

            textBoxLoginStatus.Text = "Connecting...";
            textBoxEmail.Enabled    = false;
            textBoxPassword.Enabled = false;


            if ((auth != null && textBoxEmail.Text != auth.Email) ||
                textBoxPassword.Text != "password" ||
                auth == null)
            {
                auth = new MegaUser(textBoxEmail.Text, textBoxPassword.Text);
            }

            Mega.Init(auth, (m) =>
            {
                Invoke(new Action(() =>
                                  { textBoxLoginStatus.Text = "Working."; }));
                StartSync(m, needResync);
            }, (i) =>
            {
                Invoke(new Action(() =>
                {
                    textBoxLoginStatus.Text = "Invalid login or password";
                    textBoxEmail.Enabled    = true;
                    textBoxPassword.Enabled = true;
                    buttonStart.Enabled     = true;
                    buttonExit.Enabled      = true;
                    textBoxFolder.Enabled   = true;
                    buttonStart.Enabled     = true;
                }));
            });
        }
Exemplo n.º 13
0
 public TrackingRequest(MegaUser user) : base(user)
 {
     IsTracking = true;
     TrackingId = Util.RandomString(10);
 }
Exemplo n.º 14
0
 public ServerCommandConverter(MegaUser user)
 {
     this.user = user;
 }
Exemplo n.º 15
0
 public MRequestMoveNode(MegaUser user, string nodeId, string targetNodeId) : base(user)
 {
     n = nodeId; t = targetNodeId;
 }
Exemplo n.º 16
0
 public ServerCommandConverter(MegaUser user)
 {
     this.user = user;
 }
Exemplo n.º 17
0
 public MRequestGetFiles(MegaUser user) : base(user)
 {
     this.user = user;
 }
Exemplo n.º 18
0
 public NodeKeyConverter(SymmetricAlgorithm alg, MegaUser user) : base(alg)
 {
     userId = user.Id;
 }
Exemplo n.º 19
0
 public MRequestGetUser(MegaUser user) : base(user)
 {
 }
Exemplo n.º 20
0
 public NodeKeyConverter(SymmetricAlgorithm alg, MegaUser user) : base(alg)
 {
     userId = user.Id;
 }
Exemplo n.º 21
0
 public PollingTransport(MegaUser user)
 {
     this.user = user;
 }
Exemplo n.º 22
0
        //r : ul_queue[i].retries
        //e : ul_lastreason
        //ms : ul_maxSpeed

        public MRequestGetUploadUrl(MegaUser user, long filesize) : base(user)
        {
            s = filesize;
        }
Exemplo n.º 23
0
 public NodeKeys(byte[] key, MegaUser user)
 {
     DecryptedKey = key;
     EncryptedKey = Crypto.Encrypt(user.masterKeyAlg, key); 
     Keys = new Dictionary<string,byte[]> { {user.Id, EncryptedKey} };
 }