public static Error ( string msg, Exception e, ErrorType type ) : void | ||
msg | string | |
e | Exception | |
type | ErrorType | |
return | void |
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); MainFlickrSync = new FlickrSync(); if (MainFlickrSync != null) { if (args.Length > 0) { foreach (string str in args) { if (str.ToLower().Contains(@"/auto")) { FlickrSync.autorun = true; } } } try { Application.Run(MainFlickrSync); } catch (Exception ex) { FlickrSync.Error("Unknown error detected - exiting FlickrSync.", ex, FlickrSync.ErrorType.FatalError); } } }
public RemoteInfo() { try { webClient = new WebClient(); CreateFlickrObject(); } catch (FlickrNet.Exceptions.LoginFailedInvalidTokenException invalidTokenEx) { throw invalidTokenEx; } catch (Exception ex) { FlickrSync.Error("Error connecting to flickr", ex, FlickrSync.ErrorType.Connect); } }
private void SyncFolderForm_Load(object sender, EventArgs e) { labelFolderPath.Text = sf.FolderPath; textBoxTitle.Text = sf.SetTitle; textBoxDescription.Text = sf.SetDescription; comboBoxMethod.SelectedIndex = (int)sf.SyncMethod; comboBoxFilterType.SelectedIndex = (int)sf.FilterType; comboBoxPermissions.SelectedIndex = (int)sf.Permission; checkBoxNoDelete.Checked = sf.NoDelete; checkBoxNoDeleteTags.Checked = sf.NoDeleteTags; comboBoxOrderType.SelectedIndex = (int)sf.OrderType; checkBoxNoInitialReplace.Checked = sf.NoInitialReplace; if (sf.FilterType == SyncFolder.FilterTypes.FilterIncludeTags) { labelTags.Visible = true; textBoxTags.Visible = true; textBoxTags.Text = sf.FilterTags; buttonTagList.Visible = true; } star_rating = sf.FilterStarRating; if (sf.FilterType == SyncFolder.FilterTypes.FilterStarRating) { UpdateStarRating(); } listViewSet.LargeImageList = Program.MainFlickrSync.GetImageList(); try { foreach (Photoset psi in FlickrSync.ri.GetAllSets()) { ListViewItem lvi = listViewSet.Items.Add(psi.PhotosetId, psi.Title, psi.PhotosetId); if (psi.PhotosetId == sf.SetId) { lvi.Selected = true; } } } catch (Exception ex) { FlickrSync.Error("Error loading", ex, FlickrSync.ErrorType.Normal); this.Close(); } }
public RemoteInfo() { try { f = new Flickr(Properties.Settings.Default.FlickrApiKey, Properties.Settings.Default.FlickrShared, Properties.Settings.Default.FlickrToken); f.Proxy = FlickrSync.GetProxy(true); f.OnUploadProgress += new Flickr.UploadProgressHandler(Flickr_OnUploadProgress); sets = f.PhotosetsGetList().PhotosetCollection; if (sets == null) { sets = new Photoset[0]; } string user = User(); //force access to check connection } catch (Exception ex) { FlickrSync.Error("Error connecting to flickr", ex, FlickrSync.ErrorType.Connect); } }
private void buttonTagList_Click(object sender, EventArgs e) { ArrayList taglist = new ArrayList(); FileInfo[] files = { }; ImageInfo ii = new ImageInfo(); try { DirectoryInfo dir = new DirectoryInfo(sf.FolderPath); string lookfor = "*.jpg;*.jpeg;*.gif;*.png;*.tif;*.tiff;*.bmp"; string[] extensions = lookfor.Split(new char[] { ';' }); ArrayList myfileinfos = new ArrayList(); foreach (string ext in extensions) { myfileinfos.AddRange(dir.GetFiles(ext)); } files = (FileInfo[])myfileinfos.ToArray(typeof(FileInfo)); } catch (Exception ex) { FlickrSync.Error("Error accessing path: " + sf.FolderPath, ex, FlickrSync.ErrorType.Normal); } this.Cursor = Cursors.WaitCursor; foreach (FileInfo fi in files) { try { ii.Load(fi.FullName, ImageInfo.FileTypes.FileTypeUnknown); } catch (Exception ex) { this.Cursor = Cursors.Default; FlickrSync.Error("Error loading image information: " + fi.FullName, ex, FlickrSync.ErrorType.Normal); return; } foreach (string tag in ii.GetTagsArray()) { bool exists = false; foreach (string tagexist in taglist) { if (tag == tagexist) { exists = true; break; } } if (!exists) { taglist.Add(tag); } } } this.Cursor = Cursors.Default; SelectFromList listForm = new SelectFromList(taglist); listForm.ShowDialog(); if (textBoxTags.Text == "") { textBoxTags.Text = listForm.Selected; } else { textBoxTags.Text += "; " + listForm.Selected; } }
static public WebProxy GetProxy(bool interactive) { if (!Properties.Settings.Default.ProxyUse) { return(null); } string domain_user = Properties.Settings.Default.ProxyUser; string pass = Properties.Settings.Default.ProxyPass; if (pass == "") { pass = proxy_password; } if (pass == "") { if (interactive) { Login l = new Login(domain_user, pass); if (l.ShowDialog() != DialogResult.OK) { return(null); } if (!Properties.Settings.Default.ProxyUse) { return(null); } domain_user = l.GetUser(); pass = l.GetPass(); } Properties.Settings.Default.ProxyUser = domain_user; Properties.Settings.Default.Save(); proxy_password = pass; } string domain; string proxyuser; if (domain_user.Contains(@"\")) { int pos = domain_user.IndexOf('\\'); domain = domain_user.Substring(0, pos); proxyuser = domain_user.Substring(pos + 1, domain_user.Length - pos - 1); } else { domain = ""; proxyuser = domain_user; } try { WebProxy proxyObject = new WebProxy(Properties.Settings.Default.ProxyHost, Int16.Parse(Properties.Settings.Default.ProxyPort)); proxyObject.Credentials = new NetworkCredential(proxyuser, pass, domain); return(proxyObject); } catch (Exception ex) { FlickrSync.Error("Error connecting to Proxy", ex, ErrorType.Connect); return(null); } }
public string ReplacePicture(string filename, string photoid, string title, string caption, ArrayList tags, FlickrSync.Permissions permission, bool NoDeleteTags, double?GeoLat, double?GeoLong) { string id = f.ReplacePicture(filename, photoid); f.PhotosSetMeta(id, title, caption); ArrayList specialtags = new ArrayList(); foreach (string tag in tags) { if (tag.ToLower().StartsWith("flickrsync:") || tag.ToLower().StartsWith(@"""flickrsync:")) { specialtags.Add(tag); } } foreach (string stag in specialtags) { tags.Remove(stag); string stag2 = stag.ToLower(); // To support picasa replace colons with equal sign (to be able to use flickrsync:perm:friends instead of flickrsync:perm=friends) stag2 = stag2.Replace(':', '='); if (stag2.Contains("flickrsync=perm=private")) { permission = FlickrSync.Permissions.PermPrivate; } else if (stag2.Contains("flickrsync=perm=default")) { permission = FlickrSync.Permissions.PermDefault; } else if (stag2.Contains("flickrsync=perm=familyfriends")) { permission = FlickrSync.Permissions.PermFamilyFriends; } else if (stag2.Contains("flickrsync=perm=friends")) { permission = FlickrSync.Permissions.PermFriends; } else if (stag2.Contains("flickrsync=perm=family")) { permission = FlickrSync.Permissions.PermFamily; } else if (stag2.Contains("flickrsync=perm=public")) { permission = FlickrSync.Permissions.PermPublic; } } f.PhotosSetPerms(id, permission == FlickrSync.Permissions.PermPublic, permission == FlickrSync.Permissions.PermFriends || permission == FlickrSync.Permissions.PermFamilyFriends, permission == FlickrSync.Permissions.PermFamily || permission == FlickrSync.Permissions.PermFamilyFriends, PermissionComment.Everybody, PermissionAddMeta.Everybody); string user = f.AuthCheckToken(Properties.Settings.Default.FlickrToken).User.UserId; PhotoInfoTag[] ftags = f.TagsGetListPhoto(id); //.Tags.TagCollection; if (ftags != null) { foreach (PhotoInfoTag ftag in ftags) { if (ftag.AuthorId == user) { bool found = false; for (int i = 0; i < tags.Count; i++) { if ((string)tags[i] == ftag.Raw) { found = true; tags.RemoveAt(i); break; } } if (!found && !NoDeleteTags) { f.PhotosRemoveTag(ftag.TagId); } } } } foreach (string tag in tags) { if (tag.Length > 0 && tag[0] == '"' && tag[tag.Length - 1] == '"') { f.PhotosAddTags(id, tag); } else { f.PhotosAddTags(id, @"""" + tag + @""""); } } if (GeoLat != null && GeoLong != null) { try { f.PhotosGeoSetLocation(id, (double)GeoLat, (double)GeoLong); } catch (Exception ex) { FlickrSync.Error("Error setting Geo location: " + filename + " Lat=" + GeoLat + " Long=" + GeoLong, ex, FlickrSync.ErrorType.Normal); } } return(id); }