×
Namespaces

Variants
Actions
(Difference between revisions)

Dropbox with Windows Phone

From Nokia Developer Wiki
Jump to: navigation, search
pooja_1650 (Talk | contribs)
(Pooja 1650 - - Using Sharpbox)
pooja_1650 (Talk | contribs)
(Pooja 1650 - - Loading token)
Line 75: Line 75:
 
         }
 
         }
 
</code>
 
</code>
''Remove Category:Draft when the page is complete or near complete''
 
 
 
''The "platform categories" will be displayed here in '''preview''' only - Copy paste relevant categories into text here''
 
 
{{VersionHint|Versions will be visible from this template when viewed in preview. You can delete this or leave it in the page as it is not displayed in final version}}
 
 
''Add categories below using category selector.''
 

Revision as of 08:28, 5 September 2012

This article explains how to connect Windows Phone to Dropbox cloud service by using Sharpbox

WP Metro Icon File.png
WP Metro Icon Web.png
SignpostIcon XAML 40.png
WP Metro Icon WP8.png
SignpostIcon WP7 70px.png
Article Metadata
CompatibilityArticle
Created: jupaavola (31 Aug 2012)
Last edited: pooja_1650 (05 Sep 2012)

Contents

Introduction

Some user may want to connect other cloud services than SkyDrive which is offered by Microsoft. By using Open Source project called Sharpbox, you can access to Dropbox clouds. At the time of writing this article, it is still not possible to access other clouds like CloudMe in Windows Phone although those others works with desktops.

Summary

Required software

Download Sharpbox from here: http://sharpbox.codeplex.com/ Add it as reference to your project.

For easier way I suggest to use NuGet to manage external projects, also those will be automatically referenced in to your project. More info about Nuget: http://nuget.codeplex.com/

Sharpbox prerequisities

Sharpbox needs valid Dropbox application key and secret. These you can make in Dropbox website, developers section where you create own application.

Dropbox developers: https://www.dropbox.com/developers

Sharpbox token

With Sharpbox it is also possible to use token from file to connect Dropbox. To get token use utility application named DropBoxTokenIssuer.exe that comes with Sharpbox and it is located in net40-full folder. It's Windows application, run in desktop. Then input your application key and secret to token issuer. Create empty TXT-file and write it's path to token issuer. Click authorize and program will retrieve token to this text file. Dropboxtokenissuer part.png

If you don't create empty text file where to get token, program will fail to get one.

Using Sharpbox

Sharpbox library has synchronized and asynchronized functions for many operations. For desktop usage both are fine but in Windows Phone, operating system and it's frameworks has their own limitations. All of the synchronized calls will block running UI thread and therefore the whole application. The only way to get things working is to use asynchronous functions. Some needed functions still lack of asynchronous versions, it is possible to use these by implementing own async versions to own application but more of it later.

Loading token

Include TXT-file, where you obtained token, to your project as an resource. Then read it as resource stream.

        public void ConnectCloud(string username, string password)
{
ICloudStorageConfiguration conf = CloudStorage.GetCloudConfigurationEasy(nSupportedCloudConfigurations.DropBox);
ICloudStorageAccessToken accessToken = null;
 
StreamResourceInfo sri = Application.GetResourceStream(new Uri("/DropBoxImages;component/dropboxtoken.txt", UriKind.RelativeOrAbsolute));
if (sri != null)
{
m_files.Clear();
LoadingFileList = true;
accessToken = m_dropBox.DeserializeSecurityToken(sri.Stream);
m_dropBox.BeginOpenRequest(LoginCallback, conf, accessToken);
}
}
1068 page views in the last 30 days.