Skip to content

Commit

Permalink
Merge pull request #660 from meganz/release/v3.1.1
Browse files Browse the repository at this point in the history
Release/v3.1.1
  • Loading branch information
sergiohs84 authored May 24, 2017
2 parents 8cbdd81 + e8eeea7 commit 5c2b479
Show file tree
Hide file tree
Showing 29 changed files with 471 additions and 295 deletions.
6 changes: 6 additions & 0 deletions bindings/ios/MEGADelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,12 @@
*/
- (void)onNodesUpdate:(MEGASdk *)api nodeList:(MEGANodeList *)nodeList;

/**
* @brief This function is called when the account has been updated (upgraded/downgraded)
* @param api MEGASdk object connected to the account
*/
- (void)onAccountUpdate:(MEGASdk *)api;

/**
* @brief This function is called when there are new or updated contact requests in the account
*
Expand Down
6 changes: 6 additions & 0 deletions bindings/ios/MEGAGlobalDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@
*/
- (void)onNodesUpdate:(MEGASdk *)api nodeList:(MEGANodeList *)nodeList;

/**
* @brief This function is called when the account has been updated (upgraded/downgraded)
* @param api MEGASdk object connected to the account
*/
- (void)onAccountUpdate:(MEGASdk *)api;

/**
* @brief This function is called when there are new or updated contact requests in the account
*
Expand Down
1 change: 1 addition & 0 deletions bindings/ios/Private/DelegateMEGAGlobalListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ class DelegateMEGAGlobalListener : public mega::MegaGlobalListener {

void onUsersUpdate(mega::MegaApi* api, mega::MegaUserList* userList);
void onNodesUpdate(mega::MegaApi* api, mega::MegaNodeList* nodeList);
void onAccountUpdate(mega::MegaApi *api);
void onContactRequestsUpdate(mega::MegaApi* api, mega::MegaContactRequestList* contactRequestList);
void onReloadNeeded(mega::MegaApi* api);

Expand Down
10 changes: 10 additions & 0 deletions bindings/ios/Private/DelegateMEGAGlobalListener.mm
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,16 @@
}
}

void DelegateMEGAGlobalListener::onAccountUpdate(mega::MegaApi *api) {
MEGASdk *tempMegaSDK = this->megaSDK;
id<MEGAGlobalDelegate> tempListener = this->listener;
if (listener !=nil && [listener respondsToSelector:@selector(onAccountUpdate:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[tempListener onAccountUpdate:tempMegaSDK];
});
}
}

void DelegateMEGAGlobalListener::onContactRequestsUpdate(mega::MegaApi* api, mega::MegaContactRequestList* contactRequestList) {
if (listener != nil && [listener respondsToSelector:@selector(onContactRequestsUpdate:contactRequestList:)]) {
MegaContactRequestList *tempContactRequestList = NULL;
Expand Down
1 change: 1 addition & 0 deletions bindings/ios/Private/DelegateMEGAListener.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class DelegateMEGAListener : public mega::MegaListener {
void onTransferTemporaryError(mega::MegaApi *api, mega::MegaTransfer *transfer, mega::MegaError *e);
void onUsersUpdate(mega::MegaApi* api, mega::MegaUserList* userList);
void onNodesUpdate(mega::MegaApi* api, mega::MegaNodeList* nodeList);
void onAccountUpdate(mega::MegaApi *api);
void onContactRequestsUpdate(mega::MegaApi* api, mega::MegaContactRequestList* contactRequestList);
void onReloadNeeded(mega::MegaApi *api);

Expand Down
10 changes: 10 additions & 0 deletions bindings/ios/Private/DelegateMEGAListener.mm
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,16 @@
}
}

void DelegateMEGAListener::onAccountUpdate(mega::MegaApi *api) {
MEGASdk *tempMegaSDK = this->megaSDK;
id<MEGADelegate> tempListener = this->listener;
if (listener !=nil && [listener respondsToSelector:@selector(onAccountUpdate:)]) {
dispatch_async(dispatch_get_main_queue(), ^{
[tempListener onAccountUpdate:tempMegaSDK];
});
}
}

void DelegateMEGAListener::onContactRequestsUpdate(mega::MegaApi* api, mega::MegaContactRequestList* contactRequestList) {
if (listener != nil && [listener respondsToSelector:@selector(onContactRequestsUpdate:contactRequestList:)]) {
MegaContactRequestList *tempContactRequestList = NULL;
Expand Down
10 changes: 10 additions & 0 deletions bindings/wp8/MAccountDetails.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,11 @@ uint64 MAccountDetails::getNumFolders(uint64 handle)
return accountDetails ? accountDetails->getNumFolders(handle) : 0;
}

MAccountDetails^ MAccountDetails::copy()
{
return accountDetails ? ref new MAccountDetails(accountDetails->copy(), true) : nullptr;
}

int MAccountDetails::getNumBalances()
{
return accountDetails ? accountDetails->getNumBalances() : 0;
Expand Down Expand Up @@ -177,3 +182,8 @@ uint64 MAccountDetails::getTemporalBandwidth()
{
return accountDetails ? accountDetails->getTemporalBandwidth() : 0;
}

bool MAccountDetails::isTemporalBandwidthValid()
{
return accountDetails ? accountDetails->isTemporalBandwidthValid() : false;
}
4 changes: 4 additions & 0 deletions bindings/wp8/MAccountDetails.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@ namespace mega
uint64 getNumFiles(uint64 handle);
uint64 getNumFolders(uint64 handle);

MAccountDetails^ copy();

int getNumBalances();
MAccountBalance^ getBalance(int i);

Expand All @@ -86,6 +88,8 @@ namespace mega
int getTemporalBandwidthInterval();
uint64 getTemporalBandwidth();

bool isTemporalBandwidthValid();

private:
MAccountDetails(MegaAccountDetails *accountDetails, bool cMemoryOwn);
MegaAccountDetails *accountDetails;
Expand Down
52 changes: 52 additions & 0 deletions bindings/wp8/MegaSDK.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,11 @@ bool MegaSDK::isWaiting()
return megaApi->isWaiting();
}

bool MegaSDK::areServersBusy()
{
return megaApi->areServersBusy();
}

int MegaSDK::getNumPendingUploads()
{
return megaApi->getNumPendingUploads();
Expand Down Expand Up @@ -2722,6 +2727,11 @@ void MegaSDK::updateStats()
megaApi->updateStats();
}

uint64 MegaSDK::getNumNodes()
{
return megaApi->getNumNodes();
}

uint64 MegaSDK::getTotalDownloadedBytes()
{
return megaApi->getTotalDownloadedBytes();
Expand All @@ -2732,6 +2742,16 @@ uint64 MegaSDK::getTotalUploadedBytes()
return megaApi->getTotalUploadedBytes();
}

uint64 MegaSDK::getTotalDownloadBytes()
{
return megaApi->getTotalDownloadBytes();
}

uint64 MegaSDK::getTotalUploadBytes()
{
return megaApi->getTotalUploadBytes();
}

int MegaSDK::getNumChildren(MNode^ parent)
{
return megaApi->getNumChildren((parent != nullptr) ? parent->getCPtr() : NULL);
Expand All @@ -2757,6 +2777,11 @@ MNodeList^ MegaSDK::getChildren(MNode^ parent)
return ref new MNodeList(megaApi->getChildren((parent != nullptr) ? parent->getCPtr() : NULL), true);
}

bool MegaSDK::hasChildren(MNode^ parent)
{
return megaApi->hasChildren((parent != nullptr) ? parent->getCPtr() : NULL);
}

int MegaSDK::getIndex(MNode^ node, int order)
{
return megaApi->getIndex((node != nullptr) ? node->getCPtr() : NULL, order);
Expand Down Expand Up @@ -3229,6 +3254,33 @@ MNode^ MegaSDK::authorizeNode(MNode^ node)
return ref new MNode(megaApi->authorizeNode((node != nullptr) ? node->getCPtr() : NULL), true);
}

void MegaSDK::changeApiUrl(String^ apiURL, bool disablepkp)
{
std::string utf8apiURL;
if (apiURL != nullptr)
MegaApi::utf16ToUtf8(apiURL->Data(), apiURL->Length(), &utf8apiURL);

megaApi->changeApiUrl((apiURL != nullptr) ? utf8apiURL.c_str() : NULL, disablepkp);
}

void MegaSDK::changeApiUrl(String^ apiURL)
{
std::string utf8apiURL;
if (apiURL != nullptr)
MegaApi::utf16ToUtf8(apiURL->Data(), apiURL->Length(), &utf8apiURL);

megaApi->changeApiUrl((apiURL != nullptr) ? utf8apiURL.c_str() : NULL, false);
}

bool MegaSDK::setLanguage(String^ languageCode)
{
std::string utf8languageCode;
if (languageCode != nullptr)
MegaApi::utf16ToUtf8(languageCode->Data(), languageCode->Length(), &utf8languageCode);

return megaApi->setLanguage((languageCode != nullptr) ? utf8languageCode.c_str() : NULL);
}

bool MegaSDK::createThumbnail(String^ imagePath, String^ dstPath)
{
std::string utf8imagePath;
Expand Down
9 changes: 9 additions & 0 deletions bindings/wp8/MegaSDK.h
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,7 @@ namespace mega
MTransferList^ getChildTransfers(int transferTag);

bool isWaiting();
bool areServersBusy();

//Statistics
int getNumPendingUploads();
Expand All @@ -430,15 +431,19 @@ namespace mega
void resetTotalDownloads();
void resetTotalUploads();
void updateStats();
uint64 getNumNodes();
uint64 getTotalDownloadedBytes();
uint64 getTotalUploadedBytes();
uint64 getTotalDownloadBytes();
uint64 getTotalUploadBytes();

//Filesystem
int getNumChildren(MNode^ parent);
int getNumChildFiles(MNode^ parent);
int getNumChildFolders(MNode^ parent);
MNodeList^ getChildren(MNode^ parent, int order);
MNodeList^ getChildren(MNode^ parent);
bool hasChildren(MNode^ parent);
int getIndex(MNode^ node, int order);
int getIndex(MNode^ node);
MNode^ getChildNode(MNode^ parent, String^ name);
Expand Down Expand Up @@ -511,6 +516,10 @@ namespace mega

MNode^ authorizeNode(MNode^ node);

void changeApiUrl(String^ apiURL, bool disablepkp);
void changeApiUrl(String^ apiURL);
bool setLanguage(String^ languageCode);

bool createThumbnail(String^ imagePath, String^ dstPath);
bool createPreview(String^ imagePath, String^ dstPath);

Expand Down
3 changes: 3 additions & 0 deletions examples/Swift/MEGA/MEGA.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,7 @@
TargetAttributes = {
41F175681A51E22500570E30 = {
CreatedOnToolsVersion = 6.1.1;
LastSwiftMigration = 0830;
};
};
};
Expand Down Expand Up @@ -455,6 +456,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "nz.mega.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/MEGA/MEGA-Bridging-Header.h";
SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "../../../bindings/ios ../../../include";
};
name = Debug;
Expand All @@ -470,6 +472,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "nz.mega.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OBJC_BRIDGING_HEADER = "$(SRCROOT)/MEGA/MEGA-Bridging-Header.h";
SWIFT_VERSION = 3.0;
USER_HEADER_SEARCH_PATHS = "../../../bindings/ios ../../../include";
};
name = Release;
Expand Down
36 changes: 18 additions & 18 deletions examples/Swift/MEGA/MEGA/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,62 +27,62 @@ class AppDelegate: UIResponder, UIApplicationDelegate, MEGARequestDelegate {
var window: UIWindow?
let megaapi: MEGASdk = MEGASdk(appKey: "iOS Swift/1.0", userAgent: "hNF3ELhK", basePath: nil)

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
MEGASdk.setLogLevel(MEGALogLevel.Debug)
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
MEGASdk.setLogLevel(MEGALogLevel.debug)


let storyboard = UIStoryboard(name: "Main", bundle: nil)
if (SSKeychain.passwordForService("MEGA", account: "session") != nil) {
megaapi.fastLoginWithSession(SSKeychain.passwordForService("MEGA", account: "session"), delegate: self)
if (SSKeychain.password(forService: "MEGA", account: "session") != nil) {
megaapi.fastLogin(withSession: SSKeychain.password(forService: "MEGA", account: "session"), delegate: self)

let tabBarC = storyboard.instantiateViewControllerWithIdentifier("TabBarControllerID") as! UITabBarController
let tabBarC = storyboard.instantiateViewController(withIdentifier: "TabBarControllerID") as! UITabBarController
window?.rootViewController = tabBarC

} else {
let loginVC = storyboard.instantiateViewControllerWithIdentifier("LoginViewControllerID")
let loginVC = storyboard.instantiateViewController(withIdentifier: "LoginViewControllerID")
window?.rootViewController = loginVC;
}

return true
}

func applicationWillResignActive(application: UIApplication) {
func applicationWillResignActive(_ application: UIApplication) {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}

func applicationDidEnterBackground(application: UIApplication) {
func applicationDidEnterBackground(_ application: UIApplication) {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}

func applicationWillEnterForeground(application: UIApplication) {
func applicationWillEnterForeground(_ application: UIApplication) {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}

func applicationDidBecomeActive(application: UIApplication) {
func applicationDidBecomeActive(_ application: UIApplication) {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}

func applicationWillTerminate(application: UIApplication) {
func applicationWillTerminate(_ application: UIApplication) {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}

// MARK: - MEGA Request delegate

func onRequestStart(api: MEGASdk!, request: MEGARequest!) {
if request.type == MEGARequestType.FetchNodes {
SVProgressHUD.showWithStatus("Updating nodes...")
func onRequestStart(_ api: MEGASdk!, request: MEGARequest!) {
if request.type == MEGARequestType.fetchNodes {
SVProgressHUD.show(withStatus: "Updating nodes...")
}
}

func onRequestFinish(api: MEGASdk!, request: MEGARequest!, error: MEGAError!) {
if error.type != MEGAErrorType.ApiOk {
func onRequestFinish(_ api: MEGASdk!, request: MEGARequest!, error: MEGAError!) {
if error.type != MEGAErrorType.apiOk {
return
}

if request.type == MEGARequestType.Login {
megaapi.fetchNodesWithDelegate(self)
if request.type == MEGARequestType.login {
megaapi.fetchNodes(with: self)
}
}

Expand Down
Loading

0 comments on commit 5c2b479

Please sign in to comment.