From: <ta...@us...> - 2009-01-19 10:30:51
|
Revision: 2540 http://mp-plugins.svn.sourceforge.net/mp-plugins/?rev=2540&view=rev Author: tapin Date: 2009-01-19 10:30:46 +0000 (Mon, 19 Jan 2009) Log Message: ----------- initial commit release @ version 0.0.2 Added Paths: ----------- trunk/plugins/Flicked/ trunk/plugins/Flicked/readme.txt trunk/plugins/Flicked/release/ trunk/plugins/Flicked/release/FlickrNet.dll trunk/plugins/Flicked/release/plugins/ trunk/plugins/Flicked/release/plugins/windows/ trunk/plugins/Flicked/release/plugins/windows/Flicked.dll trunk/plugins/Flicked/release/skin/ trunk/plugins/Flicked/release/skin/Blue3/ trunk/plugins/Flicked/release/skin/Blue3/flicked.xml trunk/plugins/Flicked/source/ trunk/plugins/Flicked/source/Flicked/ trunk/plugins/Flicked/source/Flicked/Flicked.csproj trunk/plugins/Flicked/source/Flicked/Flicked.csproj.user trunk/plugins/Flicked/source/Flicked/FlickedGUI.cs trunk/plugins/Flicked/source/Flicked/FlickedGet.cs trunk/plugins/Flicked/source/Flicked/FlickedReader.cs trunk/plugins/Flicked/source/Flicked/FlickedSetup.Designer.cs trunk/plugins/Flicked/source/Flicked/FlickedSetup.cs trunk/plugins/Flicked/source/Flicked/FlickedSetup.resx trunk/plugins/Flicked/source/Flicked/Properties/ trunk/plugins/Flicked/source/Flicked/Properties/AssemblyInfo.cs trunk/plugins/Flicked/source/Flicked.sln trunk/plugins/Flicked/source/Flicked.suo Added: trunk/plugins/Flicked/readme.txt =================================================================== --- trunk/plugins/Flicked/readme.txt (rev 0) +++ trunk/plugins/Flicked/readme.txt 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,12 @@ +Flicked - A Flickr Plugin for Media Portal + +Author: Tapin +Current Release: 0.0.2 + +About: +The plugin is still in early development and not yet ready for production use. +This plugin uses the c# FlickrNet libary more info @ http://www.codeplex.com/FlickrNet + +Install: +1.Copy the contents of release to your media portal directory eg C:\Program Files\Team MediaPortal\MediaPortal +2.Before using this plugin you must configure it in the MP config prgram. \ No newline at end of file Added: trunk/plugins/Flicked/release/FlickrNet.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/Flicked/release/FlickrNet.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/Flicked/release/plugins/windows/Flicked.dll =================================================================== (Binary files differ) Property changes on: trunk/plugins/Flicked/release/plugins/windows/Flicked.dll ___________________________________________________________________ Added: svn:mime-type + application/octet-stream Added: trunk/plugins/Flicked/release/skin/Blue3/flicked.xml =================================================================== --- trunk/plugins/Flicked/release/skin/Blue3/flicked.xml (rev 0) +++ trunk/plugins/Flicked/release/skin/Blue3/flicked.xml 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,125 @@ +<window> + <id>91344</id> + <defaultcontrol>50</defaultcontrol> + <allowoverlay>yes</allowoverlay> + <controls> + <control> + <type>actiongroup</type> + <description>action menu</description> + <defaultcontrol>2</defaultcontrol> + <onexit>50</onexit> + <buttonX>0</buttonX> + <buttonY>0</buttonY> + <buttonwidth>60</buttonwidth> + <buttonheight>576</buttonheight> + <textureFocus>Action_focus.png</textureFocus> + <textureNoFocus>Action_nofocus.png</textureNoFocus> + <width>320</width> + <height>720</height> + <dimColor>00ffffff</dimColor> + <control> + <type>image</type> + <posX>15</posX> + <posY>167</posY> + <width>263</width> + <height>263</height> + <texture>Backslide.png</texture> + <colorDiffuse>fffffffff</colorDiffuse> + <visible>!Control.HasFocus(50)</visible> + <animation effect="slide" time="450" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="450" end="-300,0" reversible="false">hidden</animation> + </control> + <control> + <description>group element</description> + <type>group</type> + <animation effect="slide" time="450" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="450" end="-300,0" reversible="false">hidden</animation> + <visible>!Control.HasFocus(50)</visible> + <control> + <description>group element</description> + <type>group</type> + <animation effect="slide" time="450" start="-300,0" reversible="false">visible</animation> + <animation effect="slide" time="450" end="-300,0" reversible="false">hidden</animation> + <posX>40</posX> + <posY>202</posY> + <layout>StackLayout</layout> + <visible>!Control.HasFocus(50)</visible> + <control> + <description>Photostream [RSS]</description> + <type>button</type> + <id>2</id> + <label>My Latest</label> + <onright>50</onright> + <onup>0</onup> + <ondown>0</ondown> + </control> + <control> + <description>Contacts [RSS]</description> + <type>button</type> + <id>3</id> + <label>Contacts Latest</label> + <onright>50</onright> + <ondown>0</ondown> + <onup>0</onup> + </control> + <control> + <description>Photostream [API]</description> + <type>button</type> + <id>4</id> + <label>My Photos</label> + <onright>50</onright> + <ondown>0</ondown> + <onup>0</onup> + </control> + </control> + </control> + </control> + + + + <control> + <description>BackGround</description> + <type>image</type> + <id>1</id> + <posX>0</posX> + <posY>0</posY> + <width>720</width> + <height>576</height> + <texture>background.png</texture> + </control> + + <control> + <description>an Image</description> + <type>image</type> + <id>1</id> + <posX>75</posX> + <posY>370</posY> + <texture></texture> + </control> + <control> + <description>debug box</description> + <type>textbox</type> + <id>304</id> + <posX>260</posX> + <posY>97</posY> + <width>410</width> + <height>300</height> + <spinWidth>16</spinWidth> + <spinHeight>16</spinHeight> + <spinPosX>610</spinPosX> + <spinPosY>530</spinPosY> + <spinColor>ffffffff</spinColor> + <textureUp>page_up_nofocus.png</textureUp> + <textureDown>page_down_nofocus.png</textureDown> + <textureUpFocus>page_up_focus.png</textureUpFocus> + <textureDownFocus>page_down_focus.png</textureDownFocus> + <image>icon-folder.png</image> + <font>font13</font> + <textcolor>ffffffff</textcolor> + <colordiffuse>ffffffff</colordiffuse> + </control> +<import>common.facade.pictures.xml</import> + + + </controls> +</window> \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/Flicked.csproj =================================================================== --- trunk/plugins/Flicked/source/Flicked/Flicked.csproj (rev 0) +++ trunk/plugins/Flicked/source/Flicked/Flicked.csproj 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,98 @@ +<?xml version="1.0" encoding="utf-8"?> +<Project ToolsVersion="3.5" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> + <PropertyGroup> + <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> + <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> + <ProductVersion>9.0.30729</ProductVersion> + <SchemaVersion>2.0</SchemaVersion> + <ProjectGuid>{1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}</ProjectGuid> + <OutputType>Library</OutputType> + <AppDesignerFolder>Properties</AppDesignerFolder> + <RootNamespace>Flicked</RootNamespace> + <AssemblyName>Flicked</AssemblyName> + <TargetFrameworkVersion>v3.5</TargetFrameworkVersion> + <FileAlignment>512</FileAlignment> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> + <DebugSymbols>true</DebugSymbols> + <DebugType>full</DebugType> + <Optimize>false</Optimize> + <OutputPath>bin\Debug\</OutputPath> + <DefineConstants>DEBUG;TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> + <DebugType>pdbonly</DebugType> + <Optimize>true</Optimize> + <OutputPath>bin\Release\</OutputPath> + <DefineConstants>TRACE</DefineConstants> + <ErrorReport>prompt</ErrorReport> + <WarningLevel>4</WarningLevel> + </PropertyGroup> + <ItemGroup> + <Reference Include="AxInterop.WMPLib, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\AxInterop.WMPLib.dll</HintPath> + </Reference> + <Reference Include="Core, Version=0.9.3.890, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Core.dll</HintPath> + </Reference> + <Reference Include="Dialogs, Version=0.9.3.896, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\Dialogs.dll</HintPath> + </Reference> + <Reference Include="FlickrNet, Version=2.1.5.19851, Culture=neutral, PublicKeyToken=2491df59efa5d132"> + <SpecificVersion>False</SpecificVersion> + <HintPath>deps\FlickrNet.dll</HintPath> + </Reference> + <Reference Include="System" /> + <Reference Include="System.Core"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Drawing" /> + <Reference Include="System.Windows.Forms" /> + <Reference Include="System.Xml.Linq"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data.DataSetExtensions"> + <RequiredTargetFramework>3.5</RequiredTargetFramework> + </Reference> + <Reference Include="System.Data" /> + <Reference Include="System.Xml" /> + <Reference Include="Utils, Version=2.2.6.31343, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\Utils.dll</HintPath> + </Reference> + <Reference Include="WindowPlugins, Version=0.9.4.31390, Culture=neutral, processorArchitecture=x86"> + <SpecificVersion>False</SpecificVersion> + <HintPath>..\..\..\..\..\..\..\Program Files\Team MediaPortal\MediaPortal\plugins\Windows\WindowPlugins.dll</HintPath> + </Reference> + </ItemGroup> + <ItemGroup> + <Compile Include="FlickedGet.cs" /> + <Compile Include="FlickedGUI.cs" /> + <Compile Include="FlickedReader.cs" /> + <Compile Include="FlickedSetup.cs"> + <SubType>Form</SubType> + </Compile> + <Compile Include="FlickedSetup.Designer.cs"> + <DependentUpon>FlickedSetup.cs</DependentUpon> + </Compile> + <Compile Include="Properties\AssemblyInfo.cs" /> + </ItemGroup> + <ItemGroup> + <EmbeddedResource Include="FlickedSetup.resx"> + <DependentUpon>FlickedSetup.cs</DependentUpon> + </EmbeddedResource> + </ItemGroup> + <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> + <!-- To modify your build process, add your task inside one of the targets below and uncomment it. + Other similar extension points exist, see Microsoft.Common.targets. + <Target Name="BeforeBuild"> + </Target> + <Target Name="AfterBuild"> + </Target> + --> +</Project> \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/Flicked.csproj.user =================================================================== --- trunk/plugins/Flicked/source/Flicked/Flicked.csproj.user (rev 0) +++ trunk/plugins/Flicked/source/Flicked/Flicked.csproj.user 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1 @@ +<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" /> \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/FlickedGUI.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedGUI.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedGUI.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,364 @@ +using System; +using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.ComponentModel; +using System.Windows.Forms; +using System.Net; +using System.IO; +using System.Text; +using System.Threading; +using System.Collections; + +using MediaPortal.GUI.Library; +using MediaPortal.Dialogs; +using MediaPortal.Util; +using MediaPortal.Configuration; +using MediaPortal.GUI.Pictures; + +using FlickrNet; + +namespace Flicked +{ + public class FlickedGUI : GUIWindow, ISetupForm + { + + public FlickedGUI() + { + + } + + [SkinControlAttribute(2)] + protected GUIButtonControl buttonOne = null; + [SkinControlAttribute(3)] + protected GUIButtonControl buttonTwo = null; + [SkinControlAttribute(4)] + protected GUIButtonControl buttonGetUserPhotosAPI = null; + [SkinControlAttribute(304)] + protected GUITextControl txtNotify = null; + [SkinControlAttribute(50)] + public GUIFacadeControl facadeImage = null; + + + private string strDebugText = string.Empty; + volatile bool _workerCompleted = true; + + + + private Flickr apiService = null; + //flickr setup items + private FoundUser fUser = null; + private Person fProfile = null; + + #region ISetupForm Members + + + // Returns the name of the plugin which is shown in the plugin menu + public string PluginName() + { + return "Flicked"; + } + + // Returns the description of the plugin is shown in the plugin menu + public string Description() + { + return "Flickr Utlity Plugin"; + } + + // Returns the author of the plugin which is shown in the plugin menu + public string Author() + { + return "Tapin"; + } + + // show the setup dialog + public void ShowPlugin() + { + //MessageBox.Show("Nothing to configure, this is just an example"); + FlickedSetup fs = new FlickedSetup(); + fs.ShowDialog(); + } + + // Indicates whether plugin can be enabled/disabled + public bool CanEnable() + { + return true; + } + + // Get Windows-ID + public int GetWindowId() + { + // WindowID of windowplugin belonging to this setup + // enter your own unique code + return 91344; + } + + // Indicates if plugin is enabled by default; + public bool DefaultEnabled() + { + return true; + } + + // indicates if a plugin has it's own setup screen + public bool HasSetup() + { + return true; + } + + /// <summary> + /// If the plugin should have it's own button on the main menu of MediaPortal then it + /// should return true to this method, otherwise if it should not be on home + /// it should return false + /// </summary> + /// <param name="strButtonText">text the button should have</param> + /// <param name="strButtonImage">image for the button, or empty for default</param> + /// <param name="strButtonImageFocus">image for the button, or empty for default</param> + /// <param name="strPictureImage">subpicture for the button or empty for none</param> + /// <returns>true : plugin needs it's own button on home + /// false : plugin does not need it's own button on home</returns> + + public bool GetHome(out string strButtonText, out string strButtonImage, + out string strButtonImageFocus, out string strPictureImage) + { + strButtonText = PluginName(); + strButtonImage = String.Empty; + strButtonImageFocus = String.Empty; + strPictureImage = String.Empty; + return true; + } + + + + + // With GetID it will be an window-plugin / otherwise a process-plugin + // Enter the id number here again + public override int GetID + { + get + { + return 91344; + } + + set + { + } + } + public override bool Init() + { + return Load(GUIGraphicsContext.Skin + @"\flicked.xml"); + } + #endregion + + protected override void OnPageLoad() + { + Log.Info("Flicked: started"); + Log.Debug("Loading Api Service"); + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "MediaPortal.xml"))) + { + try + { + //try to load api service + this.apiService = new Flickr(xmlwriter.GetValueAsString("flicked", "fkey", ""), xmlwriter.GetValueAsString("flicked", "fsec", ""),xmlwriter.GetValueAsString("flicked", "fapp", "")); + Log.Debug("Loaded Api Service"); + Log.Debug("Getting Frob.."); + this.fUser = apiService.TestLogin(); + Person fProfile = apiService.PeopleGetInfo(this.fUser.UserId); + Log.Debug("User Auth OK"); + } + catch (Exception exp) + { + Log.Info("Error During init: " + exp.Message); + dlgError("Plugin Init failed", "Please check the plugin setup", exp.Message); + } + + } + facadeImage.View = GUIFacadeControl.ViewMode.SmallIcons; + + } + private void dlgError(String title,String msg, String error) + { + GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_DIALOG_OK); + dlg.SetHeading(title); + dlg.SetLine(1, msg); + dlg.SetLine(3, "ERROR: " + error); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + + + protected override void OnClicked(int controlId, GUIControl control,MediaPortal.GUI.Library.Action.ActionType actionType) + { + if (control == buttonOne) + { + OnButtonOne(); + } + else if (control == buttonTwo) + { + OnButtonTwo(); + } + else if (control == buttonGetUserPhotosAPI) + { + OnButtonGetUserPhotosAPI(); + } + else if (control == facadeImage) + { + //surley a better way to do it than this think up a better way at some point + if (actionType.ToString().Equals("ACTION_SELECT_ITEM")) + { + OnFacadeImage(); + } + } + else + { + //for debugging use this helpfull thing :) + GUIDialogOK dlg = (GUIDialogOK)GUIWindowManager.GetWindow( + (int)GUIWindow.Window.WINDOW_DIALOG_OK); + dlg.SetHeading("Caught click"); + dlg.SetLine(1, "id:" + controlId.ToString()); + dlg.SetLine(2, "control:" + control.GetID.ToString()); + dlg.SetLine(3, "action:" + actionType.ToString()); + dlg.DoModal(GUIWindowManager.ActiveWindow); + } + base.OnClicked(controlId, control, actionType); + } + private void OnFacadeImage() + { + BackgroundWorker worker = new BackgroundWorker(); + worker.DoWork += new DoWorkEventHandler(DownloadImage); + worker.RunWorkerAsync(""); + while (_workerCompleted == false) + GUIWindowManager.Process(); + } + #region buttons + private void OnButtonGetUserPhotosAPI() + { + Log.Debug("API CALL: get users photos by api"); + BackgroundWorker worker = new BackgroundWorker(); + //txtNotify.Label = "WUT!"; + worker.DoWork += new DoWorkEventHandler(DownloadWorker); + worker.RunWorkerAsync("USER_API_PHOTOS"); + while (_workerCompleted == false) + GUIWindowManager.Process(); + + } + private void OnButtonOne() + { + + BackgroundWorker worker = new BackgroundWorker(); + worker.DoWork += new DoWorkEventHandler(DownloadWorker); + worker.RunWorkerAsync("USER_LATEST"); + while (_workerCompleted == false) + GUIWindowManager.Process(); + } + private void OnButtonTwo() + { + + BackgroundWorker worker = new BackgroundWorker(); + worker.DoWork += new DoWorkEventHandler(DownloadWorker); + worker.RunWorkerAsync("CONTACT_LATEST"); + while (_workerCompleted == false) + GUIWindowManager.Process(); + } + #endregion + #region internals + void DownloadImage(object sender, DoWorkEventArgs e) + { + Thread.CurrentThread.Name = "FlickedRequest"; + _workerCompleted = false; + + using (WaitCursor cursor = new WaitCursor()) + lock (this) + { + //this will take awhile + GUIListItem item = facadeImage.SelectedListItem; + FlickedGet fetcher = new FlickedGet(item.Path); + Log.Debug("Display: " + fetcher.localFile); + //make display after so we can actualy see the loading icon thing + GUISlideShow SlideShow = (GUISlideShow)GUIWindowManager.GetWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); + GUIWindowManager.ActivateWindow((int)GUIWindow.Window.WINDOW_SLIDESHOW); + SlideShow.Add(fetcher.localFile); + SlideShow.Select(fetcher.localFile); + } + _workerCompleted = true; + } + void DownloadWorker(object sender, DoWorkEventArgs e) + { + Thread.CurrentThread.Name = "FlickedRequest"; + _workerCompleted = false; + + using (WaitCursor cursor = new WaitCursor()) + lock (this) + { + try + { + //clear the display + facadeImage.Clear(); + //get user & init reader + if (e.Argument.Equals("CONTACT_LATEST") || e.Argument.Equals("USER_LATEST")) + { + FlickedReader flickReader = new FlickedReader(this.fUser.UserId); + Log.Debug("UID: " + flickReader.debuguser); + //read photo stream + Log.Debug("Operation:" + e.Argument); + if (e.Argument.Equals("CONTACT_LATEST")) + { + flickReader.ReadContactsPhotostream(); + } + else + { + flickReader.ReadMyPhotostream(); + } + //init collection + Collection<PhotoFeed.Photos> list = flickReader.PhotoList; + //draw collection title list + //DEBUGGING + //String strConcatOut = String.Empty; + Log.Debug("Items:" + list.Count); + for (int i = 0; i < list.Count; i++) + { + //DEBUGING + //strConcatOut += list[i].Title + "(" + list[i].imageUrl + "),"; + + GUIListItem item = new GUIListItem(); + item.Label = list[i].Title; + FlickedGet fetcher = new FlickedGet(list[i].thumbUrl); + item.ThumbnailImage = fetcher.localFile; + item.Label2 = list[i].author; + item.Path = list[i].imageUrl; + facadeImage.Add(item); + } + //DEBUGING + //txtNotify.Label = strConcatOut; + } + else if (e.Argument.Equals("USER_API_PHOTOS")) + { + + PhotoSearchOptions searchOptions = new PhotoSearchOptions(fUser.UserId); + //do a search and put it in set + Photos photoSet = apiService.PhotosSearch(searchOptions); + //extract from set and local cache the images + foreach (Photo photo in photoSet.PhotoCollection) + { + GUIListItem item = new GUIListItem(); + FlickedGet fetcher = new FlickedGet(photo.ThumbnailUrl); + item.ThumbnailImage = fetcher.localFile; + item.Label2 = photo.OwnerName; + item.Path = photo.LargeUrl; + facadeImage.Add(item); + } + } + + + } + catch (Exception ex) + { + //most error handling is done internaly but this might give us clues about any strange things + Log.Info("Exploded; check error for clues!"); + Log.Info(ex.ToString()); + } + + } + _workerCompleted = true; + } + #endregion + + } +} \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/FlickedGet.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedGet.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedGet.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,100 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.ComponentModel; +using System.Windows.Forms; +using System.Net; +using System.IO; +using System.Threading; +using System.Collections; +using MediaPortal.GUI.Library; +using MediaPortal.Util; +using MediaPortal.Utils; +using MediaPortal.Configuration; + +namespace Flicked +{ + /// <summary> + /// convert and image url into a usable cached image on the filesystem + /// </summary> + public class FlickedGet + { + private string _url = string.Empty; + private string _imagename = string.Empty; + private string _thumbspath = Config.GetSubFolder(Config.Dir.Thumbs, @"flicked\"); + + public string thumbspath + { + get + { + return _thumbspath; + } + } + public string localFile + { + get + { + return thumbspath + imagename; + } + } + + public string url + { + get + { + return this._url; + } + } + public string imagename + { + get + { + return this._imagename; + } + } + public FlickedGet(string sourceURL) + { + Log.Debug("starting image fetch"); + /*based of wikipedia image class*/ + _url = sourceURL; + Log.Debug("url:"+_url); + //assume the url is going to be valid + _imagename = _url.Substring(_url.LastIndexOf("/") + 1); + Log.Debug("file:" + _imagename); + //Check if we already have the file. + //Create the photo subdir in thumbs when it not exists. + if (!System.IO.Directory.Exists(thumbspath)) + { + System.IO.Directory.CreateDirectory(thumbspath); + } + + if (!System.IO.File.Exists(thumbspath + _imagename)) + { + + Log.Debug("Downloading: " + _url); + + // Here we get the image from the web and save it to disk + try + { + WebClient client = new WebClient(); + client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); + client.DownloadFile(_url, thumbspath + _imagename); + Log.Debug("Saved: " + thumbspath + _imagename); + } + catch (Exception e) + { + Log.Debug("Exception during downloading"); + Log.Debug(e.ToString()); + } + } + else + { + Log.Debug("Using Cache"); + } + Log.Debug("fetch complete"); + } + + + } +} Added: trunk/plugins/Flicked/source/Flicked/FlickedReader.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedReader.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedReader.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,145 @@ +using System; +using System.Xml; +using System.Xml.XPath; +using System.Collections.ObjectModel; +using System.Collections.Generic; +using System.ComponentModel; +using System.Windows.Forms; +using System.Net; +using System.IO; +using System.Text; +using System.Threading; +using System.Collections; +using MediaPortal.GUI.Library; +using MediaPortal.Util; +using MediaPortal.Configuration; + +namespace Flicked +{ + class FlickedReader + { + private string _strUserID = "43327308@N00"; + + private string _strFlickrUserPhotos = "http://api.flickr.com/services/feeds/photos_public.gne?lang=en-us&format=rss_200&id="; + private string _strFlickerContactPhotos = "http://api.flickr.com/services/feeds/photos_friends.gne?friends=0&display_all=1&lang=en-us&format=rss_200&user_id="; + private Collection<PhotoFeed.Photos> _photoList = new Collection<PhotoFeed.Photos>(); + + //for debugging remove at a later date + public string debuguser + { + get + { + return _strUserID; + } + } + public FlickedReader(string userid) + { + this._strUserID = userid; + } + public void ReadMyPhotostream(){ + MakeRequest(_strFlickrUserPhotos + _strUserID); + } + public void ReadContactsPhotostream() + { + MakeRequest(_strFlickerContactPhotos + _strUserID); + } + + public Collection<PhotoFeed.Photos> PhotoList + { + get { return _photoList; } + } + + /// <summary> + /// given a url to a photo RSS feed method will attempt to extract a list of photos + /// </summary> + /// <param name="uri"></param> + private void MakeRequest(string uri) + { + //string strDataOut = String.Empty; + System.Uri url = new System.Uri(uri); + Log.Debug("Starting rss read."); + //do a read + try + { + using (XmlReader reader = XmlReader.Create(uri)) + { + XmlDocument xmlDoc = new XmlDocument(); + xmlDoc.Load(reader); + Log.Debug("Grabbed Feed"); + _photoList.Clear(); + XmlNodeList nodes = xmlDoc.SelectNodes("rss/channel/item"); + Log.Debug("Selected nodes"); + foreach (XmlNode node in nodes) + { + Log.Debug("Processing node"); + //make some xpath namespace resolvers so media: type tags dont cause + //the parser to explode + XPathNavigator nav = node.CreateNavigator(); + IXmlNamespaceResolver nsResolver = nav.Clone().SelectSingleNode("//*[namespace::media]"); + + PhotoFeed.Photos item = new PhotoFeed.Photos(); + //parse off some items + XPathNavigator selectNode = nav.SelectSingleNode("media:title", nsResolver); + item.Title = selectNode.InnerXml; + Log.Debug("passed stage1"); + selectNode = nav.SelectSingleNode("media:credit", nsResolver); + item.author = selectNode.InnerXml; + Log.Debug("passed stage2"); + selectNode = nav.SelectSingleNode("media:content", nsResolver); + item.imageUrl = selectNode.GetAttribute("url", ""); + Log.Debug("passed stage3"); + selectNode = nav.SelectSingleNode("media:thumbnail", nsResolver); + item.thumbUrl = selectNode.GetAttribute("url", ""); + Log.Debug("passed stage4"); + + _photoList.Add(item); + } + } + Log.Info("Finished Parse Run"); + } + catch (Exception e) + { + Log.Debug("Exception during downloading:"); + Log.Debug(e.ToString()); + } + Log.Debug("Finished Leaving Parser"); + } + + + } + + public class PhotoFeed + { + /// <summary> + /// A structure to hold the RSS Feed items + /// </summary> + [Serializable] + public struct Photos + { + + /// <summary> + /// The title + /// </summary> + public string Title; + + /// <summary> + /// Any description associated with the photo + /// </summary> + public string description; + + /// <summary> + /// URI for the image + /// </summary> + public string imageUrl; + /// <summary> + /// URI for the tumbnail image + /// </summary> + public string thumbUrl; + + /// <summary> + /// Name of the person who took the photo + /// </summary> + public string author; + } + } +} Added: trunk/plugins/Flicked/source/Flicked/FlickedSetup.Designer.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedSetup.Designer.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedSetup.Designer.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,132 @@ +namespace Flicked +{ + partial class FlickedSetup + { + /// <summary> + /// Required designer variable. + /// </summary> + private System.ComponentModel.IContainer components = null; + + /// <summary> + /// Clean up any resources being used. + /// </summary> + /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> + protected override void Dispose(bool disposing) + { + if (disposing && (components != null)) + { + components.Dispose(); + } + base.Dispose(disposing); + } + + #region Windows Form Designer generated code + + /// <summary> + /// Required method for Designer support - do not modify + /// the contents of this method with the code editor. + /// </summary> + private void InitializeComponent() + { + this.button1 = new System.Windows.Forms.Button(); + this.textBox2 = new System.Windows.Forms.TextBox(); + this.label3 = new System.Windows.Forms.Label(); + this.label4 = new System.Windows.Forms.Label(); + this.textBox3 = new System.Windows.Forms.TextBox(); + this.linkLabel1 = new System.Windows.Forms.LinkLabel(); + this.label5 = new System.Windows.Forms.Label(); + this.SuspendLayout(); + // + // button1 + // + this.button1.Location = new System.Drawing.Point(15, 121); + this.button1.Name = "button1"; + this.button1.Size = new System.Drawing.Size(103, 35); + this.button1.TabIndex = 2; + this.button1.Text = "Auth"; + this.button1.UseVisualStyleBackColor = true; + this.button1.Click += new System.EventHandler(this.button1_Click); + // + // textBox2 + // + this.textBox2.Location = new System.Drawing.Point(15, 55); + this.textBox2.Name = "textBox2"; + this.textBox2.Size = new System.Drawing.Size(176, 20); + this.textBox2.TabIndex = 4; + // + // label3 + // + this.label3.AutoSize = true; + this.label3.Location = new System.Drawing.Point(12, 37); + this.label3.Name = "label3"; + this.label3.Size = new System.Drawing.Size(28, 13); + this.label3.TabIndex = 5; + this.label3.Text = "Key:"; + // + // label4 + // + this.label4.AutoSize = true; + this.label4.Location = new System.Drawing.Point(12, 79); + this.label4.Name = "label4"; + this.label4.Size = new System.Drawing.Size(41, 13); + this.label4.TabIndex = 6; + this.label4.Text = "Secret:"; + // + // textBox3 + // + this.textBox3.Location = new System.Drawing.Point(15, 95); + this.textBox3.Name = "textBox3"; + this.textBox3.Size = new System.Drawing.Size(176, 20); + this.textBox3.TabIndex = 7; + // + // linkLabel1 + // + this.linkLabel1.AutoSize = true; + this.linkLabel1.Location = new System.Drawing.Point(12, 9); + this.linkLabel1.Name = "linkLabel1"; + this.linkLabel1.Size = new System.Drawing.Size(93, 13); + this.linkLabel1.TabIndex = 8; + this.linkLabel1.TabStop = true; + this.linkLabel1.Text = "Get Flickr API Key"; + this.linkLabel1.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked); + // + // label5 + // + this.label5.AutoSize = true; + this.label5.Location = new System.Drawing.Point(12, 162); + this.label5.Name = "label5"; + this.label5.Size = new System.Drawing.Size(124, 13); + this.label5.TabIndex = 9; + this.label5.Text = "Ready to authenticate... "; + // + // FlickedSetup + // + this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); + this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; + this.ClientSize = new System.Drawing.Size(218, 201); + this.Controls.Add(this.label5); + this.Controls.Add(this.linkLabel1); + this.Controls.Add(this.textBox3); + this.Controls.Add(this.label4); + this.Controls.Add(this.label3); + this.Controls.Add(this.textBox2); + this.Controls.Add(this.button1); + this.Name = "FlickedSetup"; + this.Text = "FlickedSetup"; + this.ResumeLayout(false); + this.PerformLayout(); + + } + + #endregion + + private System.Windows.Forms.Button button1; + private System.Windows.Forms.TextBox textBox2; + private System.Windows.Forms.Label label3; + private System.Windows.Forms.Label label4; + private System.Windows.Forms.TextBox textBox3; + private System.Windows.Forms.LinkLabel linkLabel1; + private System.Windows.Forms.Label label5; + + } +} \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/FlickedSetup.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedSetup.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedSetup.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,105 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel; +using System.Data; +using System.Drawing; +using System.Linq; +using System.Text; +using System.Windows.Forms; +using MediaPortal.Configuration; +using MediaPortal.Util; + +using FlickrNet; + +using System.Xml; +using System.Xml.XPath; +using System.Collections.ObjectModel; + +using System.Net; +using System.IO; + +using System.Threading; +using System.Collections; +using MediaPortal.GUI.Library; + +namespace Flicked +{ + + public partial class FlickedSetup : MediaPortal.UserInterface.Controls.MPConfigForm + { + private string tempFrob; + private bool waitResponse = false; + private Flickr apiService = null; + private string flickrUrl = string.Empty; + + public FlickedSetup() + { + InitializeComponent(); + this.Text = "Flicked Setup"; + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "Mediaportal.xml"))) + { + textBox2.Text = xmlwriter.GetValueAsString("flicked", "fkey", ""); + textBox3.Text = xmlwriter.GetValueAsString("flicked", "fsec", ""); + } + } + + private void button1_Click(object sender, EventArgs e) + { + if (waitResponse) + { + button1.Text = "Re-Auth"; + + try + { + Auth auth = apiService.AuthGetToken(tempFrob); + SaveSettings(auth); + label5.Text = "Auth OK!!!"; + } + catch + { + label5.Text = "Auth check failed"; + textBox2.Enabled = true; + textBox3.Enabled = true; + } + + } + else + { + try + { + apiService = new Flickr(textBox2.Text, textBox3.Text); + // Get Frob + tempFrob = apiService.AuthGetFrob(); + // Calculate the URL at Flickr to redirect the user to + flickrUrl = apiService.AuthCalcUrl(tempFrob, AuthLevel.Read); + } + catch(Exception exp) + { + label5.Text = exp.Message; + } + waitResponse = true; + textBox2.Enabled = false; + textBox3.Enabled = false; + button1.Text = "Complete"; + label5.Text = "Auth via flickr website hit complete when done"; + System.Diagnostics.Process.Start(flickrUrl); + } + //label2.Text = textBox1.Text; + //this.Close(); + } + void SaveSettings(Auth auth) + { + using (MediaPortal.Profile.Settings xmlwriter = new MediaPortal.Profile.Settings(Config.GetFile(Config.Dir.Config, "Mediaportal.xml"))) + { + xmlwriter.SetValue("flicked", "fkey", textBox2.Text); + xmlwriter.SetValue("flicked", "fsec", textBox3.Text); + xmlwriter.SetValue("flicked", "fapp", auth.Token); + } + } + + private void linkLabel1_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) + { + System.Diagnostics.Process.Start("http://www.flickr.com/services/api/keys/"); + } + } +} Added: trunk/plugins/Flicked/source/Flicked/FlickedSetup.resx =================================================================== --- trunk/plugins/Flicked/source/Flicked/FlickedSetup.resx (rev 0) +++ trunk/plugins/Flicked/source/Flicked/FlickedSetup.resx 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,120 @@ +<?xml version="1.0" encoding="utf-8"?> +<root> + <!-- + Microsoft ResX Schema + + Version 2.0 + + The primary goals of this format is to allow a simple XML format + that is mostly human readable. The generation and parsing of the + various data types are done through the TypeConverter classes + associated with the data types. + + Example: + + ... ado.net/XML headers & schema ... + <resheader name="resmimetype">text/microsoft-resx</resheader> + <resheader name="version">2.0</resheader> + <resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader> + <resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader> + <data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data> + <data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data> + <data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64"> + <value>[base64 mime encoded serialized .NET Framework object]</value> + </data> + <data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64"> + <value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value> + <comment>This is a comment</comment> + </data> + + There are any number of "resheader" rows that contain simple + name/value pairs. + + Each data row contains a name, and value. The row also contains a + type or mimetype. Type corresponds to a .NET class that support + text/value conversion through the TypeConverter architecture. + Classes that don't support this are serialized and stored with the + mimetype set. + + The mimetype is used for serialized objects, and tells the + ResXResourceReader how to depersist the object. This is currently not + extensible. For a given mimetype the value must be set accordingly: + + Note - application/x-microsoft.net.object.binary.base64 is the format + that the ResXResourceWriter will generate, however the reader can + read any of the formats listed below. + + mimetype: application/x-microsoft.net.object.binary.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Binary.BinaryFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.soap.base64 + value : The object must be serialized with + : System.Runtime.Serialization.Formatters.Soap.SoapFormatter + : and then encoded with base64 encoding. + + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + <xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata"> + <xsd:import namespace="http://www.w3.org/XML/1998/namespace" /> + <xsd:element name="root" msdata:IsDataSet="true"> + <xsd:complexType> + <xsd:choice maxOccurs="unbounded"> + <xsd:element name="metadata"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" /> + </xsd:sequence> + <xsd:attribute name="name" use="required" type="xsd:string" /> + <xsd:attribute name="type" type="xsd:string" /> + <xsd:attribute name="mimetype" type="xsd:string" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="assembly"> + <xsd:complexType> + <xsd:attribute name="alias" type="xsd:string" /> + <xsd:attribute name="name" type="xsd:string" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="data"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + <xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" /> + <xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" /> + <xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" /> + <xsd:attribute ref="xml:space" /> + </xsd:complexType> + </xsd:element> + <xsd:element name="resheader"> + <xsd:complexType> + <xsd:sequence> + <xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" /> + </xsd:sequence> + <xsd:attribute name="name" type="xsd:string" use="required" /> + </xsd:complexType> + </xsd:element> + </xsd:choice> + </xsd:complexType> + </xsd:element> + </xsd:schema> + <resheader name="resmimetype"> + <value>text/microsoft-resx</value> + </resheader> + <resheader name="version"> + <value>2.0</value> + </resheader> + <resheader name="reader"> + <value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> + <resheader name="writer"> + <value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value> + </resheader> +</root> \ No newline at end of file Added: trunk/plugins/Flicked/source/Flicked/Properties/AssemblyInfo.cs =================================================================== --- trunk/plugins/Flicked/source/Flicked/Properties/AssemblyInfo.cs (rev 0) +++ trunk/plugins/Flicked/source/Flicked/Properties/AssemblyInfo.cs 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Flicked")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Company")] +[assembly: AssemblyProduct("Flicked")] +[assembly: AssemblyCopyright("Copyright © Company 2008")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("bccbe51d-e544-4ce8-974a-a951f5b7d75e")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Added: trunk/plugins/Flicked/source/Flicked.sln =================================================================== --- trunk/plugins/Flicked/source/Flicked.sln (rev 0) +++ trunk/plugins/Flicked/source/Flicked.sln 2009-01-19 10:30:46 UTC (rev 2540) @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual C# Express 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Flicked", "Flicked\Flicked.csproj", "{1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {1B1E7923-E40A-4536-88BA-81DFDCD8CAF1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal Added: trunk/plugins/Flicked/source/Flicked.suo =================================================================== (Binary files differ) Property changes on: trunk/plugins/Flicked/source/Flicked.suo ___________________________________________________________________ Added: svn:mime-type + application/octet-stream This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |