Exemple #1
0
        public Constants.SignInStatus  Authenticate(string encpass, string captxt, string emailstm, Gator2.Gator2Main gtmain)
        {
            if (status != Constants.SignInStatus.Authenticating)
            {
                gt         = gtmain;
                transurl   = string.Empty;
                webcookie  = string.Empty;
                token      = string.Empty;
                emailauth  = emailstm;
                captchatxt = captxt;



                authdone.Reset();
                encpwd = encpass;
                status = Constants.SignInStatus.Authenticating;
                Thread      thAuth;
                ThreadStart thAuthStart;
                thAuthStart         = new ThreadStart(AuthProc);
                thAuth              = new Thread(thAuthStart);
                thAuth.IsBackground = true;
                thAuth.Start();
                authdone.WaitOne(Timeout.Infinite);
            }
            else
            {
                //another auth in progress
            }
            return(status);
        }
Exemple #2
0
        public Plugin(Gator2.Gator2Main gtmain)
        {
            gt        = gtmain;
            FilePaths = new ArrayList();
            pInst     = new ArrayList();
            pTypes    = new ArrayList();
            FilePaths.Clear();
            pInst.Clear();
            pTypes.Clear();
            Queue plgnfiles = new Queue();

            plgnfiles.Clear();
            GGDisk disk = new GGDisk();

            disk.GetPluginDlls(ref plgnfiles);
            Count = plgnfiles.Count;
            gtmain.Log("");


            for (int i = 0; i < Count; i++)
            {
                //FilePaths[i] = plgnfiles.Dequeue();
                FilePaths.Add(plgnfiles.Dequeue());
            }

            if (Count > 0)
            {
                //ipi = new IPlugin[Count];
                gtmain.pluginsToolStripMenuItem.Enabled = true;

                for (int i = 0; i < Count; i++)
                {
                    Assembly assembly = Assembly.LoadFrom(FilePaths[i].ToString());
                    foreach (Type type in assembly.GetTypes())
                    {
                        // Pick up a class
                        if (type.IsClass == true)
                        {
                            // If it does not implement the IBase Interface, skip it
                            if (type.GetInterface("Gator.IPlugin") == null)
                            {
                                continue;
                            }
                            pTypes.Add(type);
                            // If however, it does implement the IBase Interface,
                            // create an instance of the object
                            object ibaseObject = Activator.CreateInstance(type);
                            pInst.Add(ibaseObject);

                            // Create the parameter list
                            //object[] arguments = new object[] { 10, 17.11 };
                            object result;
                            // Dynamically Invoke the Object

                            //result = type.InvokeMember("compute",
                            //                         BindingFlags.Default | BindingFlags.InvokeMethod,
                            //                         null,
                            //                         ibaseObject,
                            //                         arguments);
                            result = type.InvokeMember("Name",
                                                       BindingFlags.Default | BindingFlags.InvokeMethod,
                                                       null,
                                                       ibaseObject,
                                                       null);
                            //pNames.Add(result);
                            ToolStripMenuItem item = new ToolStripMenuItem();
                            item        = new ToolStripMenuItem();
                            item.Name   = i.ToString();
                            item.Tag    = FilePaths[i];
                            item.Text   = (string)result;
                            item.Click += new EventHandler(MenuItemClickHandler);
                            gtmain.pluginsToolStripMenuItem1.DropDownItems.Add(item);
                        }
                        //int hModule = LoadLibrary(FilePaths[i].ToString());
                        ////if (hModule == 0) break;
                        //IntPtr intPtr = GetProcAddress(hModule, "Wish");
                        //A a = (A)Marshal.GetDelegateForFunctionPointer(intPtr, typeof(A));
                        //a();
                        //FreeLibrary(hModule);
                        //gtmain.Log ("Loaded plugin : ");
                        //Assembly ass = Assembly.Load(FilePaths[i].ToString());
                        //AppDomain.CurrentDomain.Load(ass.GetName());
                        //Type t = assembly.GetType("Wish");
                        //t.e
                        //Type ObjType = null;
                        //ass =
                        //if (ass != null)
                        //    {
                        //    string args = "AdminPanel.AdminPanel";// FilePaths[i].ToString().Substring("AdminPanel.AdminPanel");
                        //    ObjType = ass.GetType(args);
                        //    if (ObjType != null)
                        //        {
                        //        ipi[i] = (IPlugin)Activator.CreateInstance(ObjType);
                        //        //ipi[i].Host = this;
                        //        }
                        //}

                        ////string name = GetPluginName ( FilePaths[i] );
                        //string name = ipi[i].GetName();

                        //ToolStripMenuItem item = new ToolStripMenuItem();
                        //item = new ToolStripMenuItem();
                        //item.Name = "dmenu" + i.ToString();
                        //item.Tag = FilePaths[i];
                        //item.Text = name;
                        //item.Click += new EventHandler(MenuItemClickHandler);
                        //gtmain.pluginsToolStripMenuItem.DropDownItems.Add(item);
                        //MessageBox.Show (name);
                    }
                }
            }
        }