Esempio n. 1
0
        public static int Run(NewOptions options, string[] args)
        {
            MeetingFile.Meeting meeting = new MeetingFile.Meeting();
            meeting.ID       = options.MeetingID;
            meeting.Password = options.Password;

            string name = options.Name;

            while (name.Length == 0)
            {
                Console.Write("Name for this meeting: ");
                name = Console.ReadLine();
            }

            while (meeting.ID.Length == 0)
            {
                Console.Write("Meeting ID: ");
                meeting.ID = Console.ReadLine();
            }

            if (meeting.Password.Length == 0)
            {
                Console.Write("Password: ");
                meeting.Password = Console.ReadLine();
            }

            return(Convert.ToInt32(MeetingFile.AddMeeting(name, meeting)));
        }
Esempio n. 2
0
        // attempt to launch a meeting from either the saved name, the URL, or the meeting id
        public static int TryLaunchFromString(string s)
        {
            // read in meeting file
            Dictionary <string, MeetingFile.Meeting> dict = MeetingFile.toObject(
                File.ReadAllText(Program.MEETING_FILE_PATH)
                );

            MeetingFile.Meeting meeting;

            // try to launch by name
            if (dict.TryGetValue(s, out meeting))
            {
                // zoommtg://zoom.us/join?confno=7731206470&zc=0&browser=chrome
                String url = "zoommtg://zoom.us/join?zc=0&stype=100&confno=" + meeting.ID;

                if (meeting.Password.Length > 0)
                {
                    url += "&pwd=" + meeting.Password;
                }

                Process.Start("open", url);
            }
            // try to launch by URL or meeting id
            else
            {
                String url = null;

                // check if URL
                if (s.Contains("https://") && s.Contains("zoom.us") && s.Contains("/j/"))
                {
                    url = "zoommtg://zoom.us/join?zc=0&stype=100&confno=" + s.Substring(s.IndexOf("/j/") + 3);
                }
                // check if meeting ID
                else if (s.All(char.IsDigit))
                {
                    url = "zoommtg://zoom.us/join?zc=0&stype=100&confno=" + s;
                }

                // attach password if link user sent contains one
                if (url.Contains("?pwd="))
                {
                    url = url.Replace("?pwd=", "&pwd=");
                }

                // if passed checks and have a URL, try it out, otherwise fail back to menu
                if (url != null)
                {
                    Process.Start("open", url);
                }
                else
                {
                    return(-1);
                }
            }

            return(0);
        }
Esempio n. 3
0
        public static int Run(UpdateOptions options, string[] args)
        {
            // parse through args
            if (options.Name.Length == 0)
            {
                List <string> trimmedArgs = new List <string>(args);
                trimmedArgs.RemoveAll(s => s.StartsWith("-") || s == "update");

                options.Name = trimmedArgs.Count > 0 ? trimmedArgs[0] : options.Name;
            }

            // if user didn't supply name of object to change
            while (options.Name.Length == 0)
            {
                Console.Write("Name of meeting to update: ");
                options.Name = Console.ReadLine();
            }

            Dictionary <string, MeetingFile.Meeting> dict = MeetingFile.toObject(
                File.ReadAllText(Program.MEETING_FILE_PATH)
                );

            MeetingFile.Meeting meeting;

            // try to update
            if (dict.TryGetValue(options.Name, out meeting))
            {
                // store in new values user supplied
                meeting.ID       = options.MeetingID.Length > 0 ? options.MeetingID : meeting.ID;
                meeting.Password = options.Password.Length > 0 ? options.Password : meeting.Password;

                // if no change, prompt user
                if (meeting.ID != options.MeetingID)
                {
                    meeting.ID = IOCommands.ReadInputWithDefault("Meeting ID: ", meeting.ID);
                }

                // if no change, prompt user
                if (meeting.Password != options.Password || meeting.Password.Length == 0)
                {
                    meeting.Password = IOCommands.ReadInputWithDefault("Meeting password: "******"Could not find meeting with name " + options.Name);
                Console.ForegroundColor = defaultColor;

                return(1);
            }
        }
Esempio n. 4
0
        private static void _setup()
        {
            // generate home directory if doesn't exist
            if (!Directory.Exists(DIRECTORY_PATH))
            {
                Directory.CreateDirectory(DIRECTORY_PATH);
            }

            // generate tracking file if doesn't exist
            if (!File.Exists(MEETING_FILE_PATH))
            {
                File.WriteAllText(MEETING_FILE_PATH, MeetingFile.GenerateEmptyFileContents());
            }
        }
Esempio n. 5
0
        public static int Run(DeleteOptions options, string[] args)
        {
            // figure out name to delete
            List <string> trimmedArgs = new List <string>(args);

            trimmedArgs.RemoveAll(s => s.StartsWith("-") || s == "delete");

            string nameToDelete = trimmedArgs.Count > 0 ? trimmedArgs[0] : "";

            // if user didn't supply name of object to delete
            while (nameToDelete.Length == 0)
            {
                Console.Write("Name of meeting to delete: ");
                nameToDelete = Console.ReadLine();
            }

            MeetingFile.RemoveMeeting(nameToDelete);
            return(0);
        }
Esempio n. 6
0
        public static int Run(ListOptions options, string[] args)
        {
            Dictionary <string, MeetingFile.Meeting> dict = MeetingFile.toObject(
                File.ReadAllText(Program.MEETING_FILE_PATH)
                );

            if (dict.Count == 0)
            {
                Console.WriteLine("No saved zoom meetings.");
                Console.WriteLine("Run zoom new to save a meeting.");
            }
            else
            {
                Console.WriteLine();

                foreach (string name in dict.Keys)
                {
                    Console.WriteLine(name + ":");

                    MeetingFile.Meeting meeting;

                    if (dict.TryGetValue(name, out meeting))
                    {
                        Console.WriteLine("  Meeting ID: " + meeting.ID);
                        Console.WriteLine("  Password ID: " + (meeting.Password.Length > 0 ? meeting.Password : "******"));
                        Console.WriteLine();
                    }
                    else
                    {
                        ConsoleColor defaultColor = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.Red;
                        Console.WriteLine("Encountered an error reading the stored data.");
                        Console.ForegroundColor = defaultColor;

                        return(1);
                    }
                }
            }

            return(0);
        }
Esempio n. 7
0
        public static int Run(LaunchOptions options, string[] args)
        {
            if (options.MeetingID.Length > 0)
            {
                String url = "zoommtg://zoom.us/join?zc=0&stype=100&confno=" + options.MeetingID;

                if (options.Password.Length > 0)
                {
                    url += "&pwd=" + options.Password;
                }

                Process.Start("open", url);
            }
            else
            {
                string nameToLaunch = options.Name;

                // figure out name to launch if user didn't supply one
                if (nameToLaunch.Length == 0)
                {
                    // parse through args
                    List <string> trimmedArgs = new List <string>(args);
                    trimmedArgs.RemoveAll(s => s.StartsWith("-") || s == "launch");

                    nameToLaunch = trimmedArgs.Count > 0 ? trimmedArgs[0] : "";

                    // if user still didn't supply name of object to launch, ask
                    while (nameToLaunch.Length == 0)
                    {
                        Console.Write("Name of meeting to launch: ");
                        nameToLaunch = Console.ReadLine();
                    }
                }

                // find meeting in meeting file
                Dictionary <string, MeetingFile.Meeting> dict = MeetingFile.toObject(
                    File.ReadAllText(Program.MEETING_FILE_PATH)
                    );

                MeetingFile.Meeting meeting;

                // try to grab and launch
                if (dict.TryGetValue(nameToLaunch, out meeting))
                {
                    // zoommtg://zoom.us/join?confno=7731206470&zc=0&browser=chrome
                    String url = "zoommtg://zoom.us/join?zc=0&stype=100&confno=" + meeting.ID;

                    if (meeting.Password.Length > 0)
                    {
                        url += "&pwd=" + meeting.Password;
                    }

                    Process.Start("open", url);
                }
                else
                {
                    // print out error message
                    ConsoleColor defaultColor = Console.ForegroundColor;
                    Console.ForegroundColor = ConsoleColor.Red;
                    Console.WriteLine("Could not find meeting with name " + nameToLaunch);
                    Console.ForegroundColor = defaultColor;

                    return(1);
                }
            }

            return(0);
        }