Beispiel #1
0
        public GoogleDocs(string url, Dictionary<string, string> options)
        {
            var uri = new Utility.Uri(url);
            m_folder = uri.HostAndPath;
            if (m_folder.EndsWith("/"))
                m_folder = m_folder.Substring(0, m_folder.Length - 1);

            string username = null;
            string password = null;

            if (options.ContainsKey("auth-username"))
                username = options["auth-username"];
            if (options.ContainsKey("auth-password"))
                password = options["auth-password"];
            if (options.ContainsKey(USERNAME_OPTION))
                username = options[USERNAME_OPTION];
            if (options.ContainsKey(PASSWORD_OPTION))
                password = options[PASSWORD_OPTION];
            if (!string.IsNullOrEmpty(uri.Username))
                username = uri.Username;
            if (!string.IsNullOrEmpty(uri.Password))
                password = uri.Password;

            string labels;
            if (!options.TryGetValue(ATTRIBUTES_OPTION, out labels))
                labels = DEFAULT_LABELS;

            m_labels = (labels ?? "").Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);

            if (string.IsNullOrEmpty(username))
                throw new Exception(Strings.GoogleDocs.MissingUsernameError);
            if (string.IsNullOrEmpty(password))
                throw new Exception(Strings.GoogleDocs.MissingPasswordError);

            m_cla = new Google.GData.Client.ClientLoginAuthenticator(USER_AGENT, Google.GData.Client.ServiceNames.Documents, username, password);

            m_settings = new Google.GData.Client.RequestSettings(USER_AGENT, username, password);
            m_settings.AutoPaging = true;
        }
Beispiel #2
0
        public GoogleDocs(string url, Dictionary<string, string> options)
        {
            Match m = URL_PARSER.Match(url);
            if (!m.Success)
                throw new Exception(string.Format(Strings.GoogleDocs.InvalidUrlError, url));

            m_folder = m.Groups["folder"].Value;
            if (m_folder.EndsWith("/"))
                m_folder = m_folder.Substring(0, m_folder.Length - 1);

            string username = null;
            string password = null;

            if (options.ContainsKey("ftp-username"))
                username = options["ftp-username"];
            if (options.ContainsKey("ftp-password"))
                password = options["ftp-password"];
            if (options.ContainsKey(USERNAME_OPTION))
                username = options[USERNAME_OPTION];
            if (options.ContainsKey(PASSWORD_OPTION))
                password = options[PASSWORD_OPTION];

            string labels;
            if (!options.TryGetValue(ATTRIBUTES_OPTION, out labels))
                labels = DEFAULT_LABELS;

            m_labels = (labels ?? "").Split(new string[] {","}, StringSplitOptions.RemoveEmptyEntries);

            if (string.IsNullOrEmpty(username))
                throw new Exception(Strings.GoogleDocs.MissingUsernameError);
            if (string.IsNullOrEmpty(password))
                throw new Exception(Strings.GoogleDocs.MissingPasswordError);

            m_cla = new Google.GData.Client.ClientLoginAuthenticator(USER_AGENT, Google.GData.Client.ServiceNames.Documents, username, password);

            m_settings = new Google.GData.Client.RequestSettings(USER_AGENT, username, password);
            m_settings.AutoPaging = true;
            m_service = new Google.GData.Client.Service();
        }
Beispiel #3
0
 public void Dispose()
 {
     m_settings = null;
     m_cla = null;
 }
Beispiel #4
0
        public GoogleDocs(string url, Dictionary <string, string> options)
        {
            var uri = new Utility.Uri(url);

            m_folder = uri.HostAndPath;
            if (m_folder.EndsWith("/"))
            {
                m_folder = m_folder.Substring(0, m_folder.Length - 1);
            }

            string username = null;
            string password = null;

            if (options.ContainsKey("auth-username"))
            {
                username = options["auth-username"];
            }
            if (options.ContainsKey("auth-password"))
            {
                password = options["auth-password"];
            }
            if (options.ContainsKey(USERNAME_OPTION))
            {
                username = options[USERNAME_OPTION];
            }
            if (options.ContainsKey(PASSWORD_OPTION))
            {
                password = options[PASSWORD_OPTION];
            }
            if (!string.IsNullOrEmpty(uri.Username))
            {
                username = uri.Username;
            }
            if (!string.IsNullOrEmpty(uri.Password))
            {
                password = uri.Password;
            }

            string labels;

            if (!options.TryGetValue(ATTRIBUTES_OPTION, out labels))
            {
                labels = DEFAULT_LABELS;
            }

            m_labels = (labels ?? "").Split(new string[] { "," }, StringSplitOptions.RemoveEmptyEntries);

            if (string.IsNullOrEmpty(username))
            {
                throw new Exception(Strings.GoogleDocs.MissingUsernameError);
            }
            if (string.IsNullOrEmpty(password))
            {
                throw new Exception(Strings.GoogleDocs.MissingPasswordError);
            }

            m_cla = new Google.GData.Client.ClientLoginAuthenticator(USER_AGENT, Google.GData.Client.ServiceNames.Documents, username, password);

            m_settings            = new Google.GData.Client.RequestSettings(USER_AGENT, username, password);
            m_settings.AutoPaging = true;
        }
Beispiel #5
0
 public void Dispose()
 {
     m_settings = null;
     m_cla      = null;
 }