Permalink
Browse files

Added some new apis

  • Loading branch information...
Alxandr committed Feb 25, 2013
1 parent 1c57564 commit 3aa0504b18933b74cdfb3a487d1b63cdb0186c8d
@@ -394,4 +394,74 @@ namespace SpotiFire {
/// <summary> An enum constant representing the no albums option. </summary>
NoAlbums = 2,
};
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Values that represent a type of internet-connection. </summary>
+ ///
+ /// <remarks> Aleksander, 24.02.2013. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ public enum class ConnectionType
+ {
+ /// <summary> An enum constant representing the unknown option. </summary>
+ Unknown,
+ /// <summary> An enum constant representing the none option. </summary>
+ None,
+ /// <summary> An enum constant representing the mobile option. </summary>
+ Mobile,
+ /// <summary> An enum constant representing the mobile roaming option. </summary>
+ MobileRoaming,
+ /// <summary> An enum constant representing the wifi option. </summary>
+ Wifi,
+ /// <summary> An enum constant representing the wired option. </summary>
+ Wired
+ };
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Values that represent connection rules. </summary>
+ ///
+ /// <remarks> Connection rules, bitwise OR of flags. The default is The default is Network | AllowSync. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ [System::Flags]
+ public enum class ConnectionRules
+ {
+ /// <summary> An enum constant representing the none option. </summary>
+ None = 0x0,
+ /// <summary> An enum constant representing the network option. </summary>
+ Network = 0x1,
+ /// <summary> An enum constant representing the network if roaming option. </summary>
+ NetworkIfRoaming = 0x2,
+ /// <summary> An enum constant representing the allow synchronise over mobile option. </summary>
+ AllowSyncOverMobile = 0x4,
+ /// <summary> An enum constant representing the allow synchronise over wifi option. </summary>
+ AllowSyncOverWifi = 0x8
+ };
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Values that represent a social provider. </summary>
+ ///
+ /// <remarks> Aleksander, 24.02.2013. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ public enum class SocialProvider
+ {
+ /// <summary> An enum constant representing the spotify option. </summary>
+ Spotify,
+ /// <summary> An enum constant representing the facebook option. </summary>
+ Facebook,
+ /// <summary> An enum constant representing the last fm option. </summary>
+ LastFm
+ };
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Values that represent . </summary>
+ ///
+ /// <remarks> Aleksander, 24.02.2013. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ public enum class ScrobblingState
+ {
+ UseGlobalSetting = 0,
+ LocalEnabled,
+ LocalDisabled,
+ GlobalEnabled,
+ GlobalDisabled
+ };
}
@@ -255,11 +255,13 @@ Session ^Session::SelfSession::get() {
ConnectionState Session::ConnectionState::get() {
logger->Trace("get_ConnectionState");
+ SPLock lock;
return ENUM(SpotiFire::ConnectionState, sp_session_connectionstate(_ptr));
}
Task<Error> ^Session::Login(String ^username, String ^password, bool remember) {
logger->Trace("Login");
+ SPLock lock;
marshal_context context;
_login = gcnew TaskCompletionSource<Error>();
sp_session_login(_ptr, context.marshal_as<const char *>(username), context.marshal_as<const char *>(password), remember, NULL);
@@ -268,35 +270,59 @@ Task<Error> ^Session::Login(String ^username, String ^password, bool remember) {
Task<Error> ^Session::Relogin() {
logger->Trace("Relogin");
+ SPLock lock;
_login = gcnew TaskCompletionSource<Error>();
sp_session_relogin(_ptr);
return _login->Task;
}
Task ^Session::Logout() {
logger->Trace("Logout");
+ SPLock lock;
_logout = gcnew TaskCompletionSource<bool>();
sp_session_logout(_ptr);
return _logout->Task;
}
+void Session::ForgetMe() {
+ logger->Trace("ForgetMe");
+ SPLock lock;
+ SP_ERR(sp_session_forget_me(_ptr));
+}
+
+void Session::FlushCaches() {
+ logger->Trace("FlushCaches");
+ SPLock lock;
+ SP_ERR(sp_session_flush_caches(_ptr));
+}
+
void Session::PlayerLoad(Track ^track) {
logger->Trace("PlayerLoad");
+ SPLock lock;
SP_ERR(sp_session_player_load(_ptr, track->_ptr));
}
void Session::PlayerPause() {
logger->Trace("PlayerPause");
+ SPLock lock;
SP_ERR(sp_session_player_play(_ptr, false));
}
void Session::PlayerPlay() {
logger->Trace("PlayerPlay");
+ SPLock lock;
SP_ERR(sp_session_player_play(_ptr, true));
}
+void Session::PlayerPrefetch(Track ^track) {
+ logger->Trace("PlayerPrefetch");
+ SPLock lock;
+ SP_ERR(sp_session_player_prefetch(_ptr, track->_ptr));
+}
+
void Session::PlayerSeek(int offset) {
logger->Trace("PlayerSeek");
+ SPLock lock;
SP_ERR(sp_session_player_seek(_ptr, offset));
}
@@ -306,6 +332,7 @@ void Session::PlayerSeek(TimeSpan offset) {
void Session::PlayerUnload() {
logger->Trace("PlayerUnload");
+ SPLock lock;
SP_ERR(sp_session_player_unload(_ptr));
}
@@ -327,9 +354,74 @@ Playlist ^Session::Starred::get() {
return ret;
}
-void Session::PrefferedBitrate::set(BitRate bitRate) {
- logger->Trace("set_PrefferedBitrate");
- sp_session_preferred_bitrate(_ptr, (sp_bitrate)bitRate);
+String ^Session::UserName::get() {
+ logger->Trace("get_UserName");
+ SPLock lock;
+ return UTF8(sp_session_user_name(_ptr));
+}
+
+String ^Session::RememberedUser::get() {
+ logger->Trace("get_RememberedUser");
+ SPLock lock;
+ int length = sp_session_remembered_user(_ptr, NULL, 0);
+ if(length == -1)
+ return nullptr;
+ std::vector<char> data(length);
+ return UTF8(data);
+}
+
+void Session::CacheSize::set(int size) {
+ logger->Trace("set_CacheSize");
+ SPLock lock;
+ SP_ERR(sp_session_set_cache_size(_ptr, size));
+}
+
+bool Session::VolumeNormalization::get() {
+ logger->Trace("get_VolumeNormalization");
+ SPLock lock;
+ return sp_session_get_volume_normalization(_ptr);
+}
+
+void Session::VolumeNormalization::set(bool value) {
+ logger->Trace("set_VolumeNormalization");
+ SPLock lock;
+ SP_ERR(sp_session_set_volume_normalization(_ptr, value));
+}
+
+bool Session::PrivateSession::get() {
+ logger->Trace("get_PrivateSession");
+ SPLock lock;
+ return sp_session_is_private_session(_ptr);
+}
+
+void Session::PrivateSession::set(bool value) {
+ logger->Trace("set_PrivateSession");
+ SPLock lock;
+ SP_ERR(sp_session_set_private_session(_ptr, value));
+}
+
+void Session::PreferredBitrate::set(BitRate bitRate) {
+ logger->Trace("set_PreferredBitrate");
+ SPLock lock;
+ SP_ERR(sp_session_preferred_bitrate(_ptr, (sp_bitrate)bitRate));
+}
+
+void Session::PreferredOfflineBitrate::set(BitRate bitRate) {
+ logger->Trace("set_PreferredOfflineBitrate");
+ SPLock lock;
+ SP_ERR(sp_session_preferred_offline_bitrate(_ptr, (sp_bitrate)bitRate, false /*TODO: incorporate?*/));
+}
+
+void Session::ConnectionType::set(SpotiFire::ConnectionType type) {
+ logger->Trace("set_ConnectionType");
+ SPLock lock;
+ SP_ERR(sp_session_set_connection_type(_ptr, (sp_connection_type)type));
+}
+
+void Session::ConnectionRules::set(SpotiFire::ConnectionRules rules) {
+ logger->Trace("set_ConnectionRules");
+ SPLock lock;
+ SP_ERR(sp_session_set_connection_rules(_ptr, (sp_connection_rules)rules));
}
//------------------ Event Handlers ------------------//
@@ -82,6 +82,20 @@ namespace SpotiFire {
///-------------------------------------------------------------------------------------------------
virtual property ConnectionState ConnectionState { SpotiFire::ConnectionState get() sealed; }
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Sets the type of the connection. </summary>
+ ///
+ /// <value> The type of the connection. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property ConnectionType ConnectionType { void set(SpotiFire::ConnectionType type) sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Sets the connection rules. </summary>
+ ///
+ /// <value> The connection rules. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property ConnectionRules ConnectionRules { void set(SpotiFire::ConnectionRules rules) sealed; }
+
///-------------------------------------------------------------------------------------------------
/// <summary> Logs in the specified username/password combo. This initiates the login in the background.
/// An application MUST NEVER store the user's password in clear text. If automatic relogin is
@@ -125,6 +139,20 @@ namespace SpotiFire {
///-------------------------------------------------------------------------------------------------
virtual Task ^Logout() sealed;
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Forget me. </summary>
+ ///
+ /// <remarks> Aleksander, 24.02.2013. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ virtual void ForgetMe() sealed;
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Flushes the caches. </summary>
+ ///
+ /// <remarks> This will make libspotify write all data that is meant to be stored on disk to the disk immediately. libspotify does this periodically by itself and also on logout. So under normal conditions this should never need to be used. </remarks>
+ ///-------------------------------------------------------------------------------------------------
+ virtual void FlushCaches() sealed;
+
///-------------------------------------------------------------------------------------------------
/// <summary> Loads the specified track. </summary>
///
@@ -185,6 +213,15 @@ namespace SpotiFire {
///-------------------------------------------------------------------------------------------------
virtual void PlayerUnload() sealed;
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Prefetch a track. </summary>
+ ///
+ /// <remarks> Instruct libspotify to start loading of a track into its cache. This could be done by an application just before the current track ends. </remarks>
+ ///
+ /// <param name="track"> The track to be prefetched. </param>
+ ///-------------------------------------------------------------------------------------------------
+ virtual void PlayerPrefetch(Track ^track) sealed;
+
///-------------------------------------------------------------------------------------------------
/// <summary> Gets the playlist container. </summary>
///
@@ -200,11 +237,53 @@ namespace SpotiFire {
virtual property SpotiFire::Playlist ^Starred { SpotiFire::Playlist ^get() sealed; }
///-------------------------------------------------------------------------------------------------
- /// <summary> Sets the preffered bitrate. </summary>
+ /// <summary> Sets the preferred bitrate. </summary>
+ ///
+ /// <value> The preferred bitrate. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property BitRate PreferredBitrate { void set(BitRate bitRate) sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Sets the preferred offline bitrate. </summary>
+ ///
+ /// <value> The preferred offline bitrate. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property BitRate PreferredOfflineBitrate { void set(BitRate bitRate) sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Gets or sets a value indicating whether to use volume normalization. </summary>
+ ///
+ /// <value> true if volume normalization is on, false if not. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property bool VolumeNormalization { bool get() sealed; void set(bool value) sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Gets or sets a value indicating whether the private session. </summary>
+ ///
+ /// <value> true if private session, false if not. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property bool PrivateSession { bool get() sealed; void set(bool value) sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Gets the name of the user. </summary>
+ ///
+ /// <value> The name of the user. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property String ^UserName { String ^get() sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Gets the remembered user. </summary>
+ ///
+ /// <value> The remembered user. </value>
+ ///-------------------------------------------------------------------------------------------------
+ virtual property String ^RememberedUser { String ^get() sealed; }
+
+ ///-------------------------------------------------------------------------------------------------
+ /// <summary> Set maximum cache size. </summary>
///
- /// <value> The preffered bitrate. </value>
+ /// <value> Maximum cache size in megabytes. Setting it to 0 (the default) will let libspotify automatically resize the cache (10% of disk free space). </value>
///-------------------------------------------------------------------------------------------------
- virtual property BitRate PrefferedBitrate { void set(BitRate bitRate) sealed; }
+ virtual property int CacheSize { void set(int cahceSize) sealed; }
/// <summary> [Not implemented] Event queue for all listeners interested in ConnectionError events. </summary>
event SessionEventHandler ^ConnectionError;
Oops, something went wrong.

0 comments on commit 3aa0504

Please sign in to comment.