Skip to content

Commit

Permalink
Merge pull request #19 from meganz/release/v0.9.9
Browse files Browse the repository at this point in the history
Release/v0.9.9
  • Loading branch information
sergiohs84 authored Jul 28, 2017
2 parents 5f562ee + 4b08d6c commit 35ff258
Show file tree
Hide file tree
Showing 25 changed files with 2,149 additions and 36 deletions.
4 changes: 4 additions & 0 deletions bindings/Objective-C/MEGAChatSdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -188,4 +188,8 @@ typedef NS_ENUM (NSInteger, MEGAChatInit) {
+ (void)setLogObject:(id<MEGAChatLoggerDelegate>)delegate;
+ (void)setLogWithColors:(BOOL)userColors;

#pragma mark - Exceptions

+ (void)setCatchException:(BOOL)enable;

@end
4 changes: 4 additions & 0 deletions bindings/Objective-C/MEGAChatSdk.mm
Original file line number Diff line number Diff line change
Expand Up @@ -609,4 +609,8 @@ - (void)freeChatListener:(DelegateMEGAChatListener *)delegate {
delete delegate;
}

+ (void)setCatchException:(BOOL)enable {
MegaChatApi::setCatchException(enable);
}

@end
81 changes: 81 additions & 0 deletions bindings/java/nz/mega/sdk/DelegateMegaChatListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/*
* (c) 2013-2015 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* @copyright Simplified (2-clause) BSD License.
* You should have received a copy of the license along with this
* program.
*/
package nz.mega.sdk;

class DelegateMegaChatListener extends MegaChatListener {

MegaChatApiJava megaChatApi;
MegaChatListenerInterface listener;

DelegateMegaChatListener(MegaChatApiJava megaApi, MegaChatListenerInterface listener) {
this.megaChatApi = megaApi;
this.listener = listener;
}

MegaChatListenerInterface getUserListener() {
return listener;
}

@Override
public void onChatListItemUpdate(MegaChatApi api, MegaChatListItem item)
{
if (listener != null) {
final MegaChatListItem megaChatListItem = item.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onChatListItemUpdate(megaChatApi, megaChatListItem);
}
});
}
}

@Override
public void onChatInitStateUpdate(MegaChatApi api, final int newState)
{
if (listener != null) {
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onChatInitStateUpdate(megaChatApi, newState);
}
});
}
}

@Override
public void onChatOnlineStatusUpdate(MegaChatApi api, final long userhandle, final int status, final boolean inProgress)
{
if (listener != null) {
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onChatOnlineStatusUpdate(megaChatApi, userhandle, status, inProgress);
}
});
}
}

@Override
public void onChatPresenceConfigUpdate(MegaChatApi api, final MegaChatPresenceConfig config)
{
if (listener != null) {
final MegaChatPresenceConfig megaChatPresenceConfig = config.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onChatPresenceConfigUpdate(megaChatApi, megaChatPresenceConfig);
}
});
}
}
}
60 changes: 60 additions & 0 deletions bindings/java/nz/mega/sdk/DelegateMegaChatLogger.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
/*
* (c) 2013-2015 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* @copyright Simplified (2-clause) BSD License.
* You should have received a copy of the license along with this
* program.
*/
package nz.mega.sdk;

import java.lang.String;

/**
* Interface to receive SDK logs.
* You can implement this class and pass an object of your subclass to MegaApiJava.setLoggerClass()
* to receive SDK logs. You will also have to use MegaApiJava.setLogLevel() to select the level of
* the logs that you want to receive.
*
* @see MegaChatLoggerInterface
* @see MegaChatLogger
*/
class DelegateMegaChatLogger extends MegaChatLogger {
MegaChatLoggerInterface listener;

DelegateMegaChatLogger(MegaChatLoggerInterface listener) {
this.listener = listener;
}

/**
* This function will be called with all logs with level <= your selected level of logging.
* By default logging level is MegaApi.LOG_LEVEL_INFO.
*
* @param loglevel
* Log level of this message.
* Valid values are: <br>
* - LOG_LEVEL_FATAL = 0. <br>
* - LOG_LEVEL_ERROR = 1. <br>
* - LOG_LEVEL_WARNING = 2. <br>
* - LOG_LEVEL_INFO = 3. <br>
* - LOG_LEVEL_DEBUG = 4. <br>
* - LOG_LEVEL_MAX = 5.
* @param message
* Log message.
* The SDK retains the ownership of this string, it will be valid after this function returns.
* @see MegaChatLoggerInterface#log(int loglevel, String message)
* @see MegaChatLogger#log(int loglevel, String message)
*/
public void log(int loglevel, String message) {
if (listener != null) {
listener.log(loglevel, message);
}
}
}
162 changes: 162 additions & 0 deletions bindings/java/nz/mega/sdk/DelegateMegaChatRequestListener.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,162 @@
/*
* (c) 2013-2015 by Mega Limited, Auckland, New Zealand
*
* This file is part of the MEGA SDK - Client Access Engine.
*
* Applications using the MEGA API must present a valid application key
* and comply with the the rules set forth in the Terms of Service.
*
* The MEGA SDK is distributed in the hope that it will be useful,\
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
* @copyright Simplified (2-clause) BSD License.
* You should have received a copy of the license along with this
* program.
*/
package nz.mega.sdk;

/**
* Interface to receive information about requests.
* <p>
* All requests allows to pass a pointer to an implementation of this interface in the last parameter.
* You can also get information about all requests using MegaApi.addRequestListener().
* MegaListener objects can also receive information about requests.
* This interface uses MegaRequest objects to provide information about requests.
* Please note that not all fields of MegaRequest objects are valid for all requests.
* See the documentation about each request to know which fields contain useful information for each one.
*
* @see MegaChatRequestListenerInterface
* @see MegaChatRequestListener
*/
class DelegateMegaChatRequestListener extends MegaChatRequestListener {

MegaChatApiJava megaChatApi;
MegaChatRequestListenerInterface listener;
boolean singleListener;

DelegateMegaChatRequestListener(MegaChatApiJava megaApi, MegaChatRequestListenerInterface listener, boolean singleListener) {
this.megaChatApi = megaApi;
this.listener = listener;
this.singleListener = singleListener;
}

MegaChatRequestListenerInterface getUserListener() {
return listener;
}

/**
* This function is called when a request is about to start being processed.
* <p>
* The SDK retains the ownership of the request parameter. Do not use it after this functions returns.
* The api object is the one created by the application, it will be valid until the application deletes it.
*
* @param api
* API that started the request.
* @param request
* Information about the request.
* @see MegaRequestListenerInterface#onRequestStart(MegaApiJava api, MegaRequest request)
* @see MegaRequestListener#onRequestStart(MegaApi api, MegaRequest request)
*/
@Override
public void onRequestStart(MegaChatApi api, MegaChatRequest request) {
if (listener != null) {
final MegaChatRequest megaRequest = request.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onRequestStart(megaChatApi, megaRequest);
}
});
}
}

/**
* This function is called to get details about the progress of a request.
* <p>
* Currently, this callback is only used for fetchNodes requests (MegaRequest.TYPE_FETCH_NODES).
* The SDK retains the ownership of the request parameter. Do not use it after this function returns.
* The api object is the one created by the application, it will be valid until the application deletes it.
*
* @param api
* API that started the request.
* @param request
* Information about the request.
* @see MegaRequestListenerInterface#onRequestUpdate(MegaApiJava api, MegaRequest request)
* @see MegaRequestListener#onRequestUpdate(MegaApi api, MegaRequest request)
*/
@Override
public void onRequestUpdate(MegaChatApi api, MegaChatRequest request) {
if (listener != null) {
final MegaChatRequest megaRequest = request.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onRequestUpdate(megaChatApi, megaRequest);
}
});
}
}

/**
* This function is called when a request has finished.
* <p>
* There will be no further callbacks related to this request.
* The MegaError parameter provides the result of the request.
* If the request completed without problems, the error code will be API_OK. The SDK retains the ownership
* of the request and error parameters. Do not use them after this functions returns.
* The api object is the one created by the application, it will be valid until the application deletes it.
*
* @param api
* API that started the request.
* @param request
* Information about the request.
* @param e
* Error Information.
* @see MegaRequestListenerInterface#onRequestFinish(MegaApiJava api, MegaRequest request, MegaError e)
* @see MegaRequestListener#onRequestFinish(MegaApi api, MegaRequest request, MegaError e)
*/
@Override
public void onRequestFinish(MegaChatApi api, MegaChatRequest request, MegaChatError e) {
if (listener != null) {
final MegaChatRequest megaRequest = request.copy();
final MegaChatError megaError = e.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onRequestFinish(megaChatApi, megaRequest, megaError);

if (singleListener) {
megaChatApi.privateFreeRequestListener(DelegateMegaChatRequestListener.this);
}
}
});
}
}

/**
* This function is called when there is a temporary error processing a request.
* <p>
* The request continues after this callback, so expect more MegaRequestListener.onRequestTemporaryError
* or a MegaRequestListener.onRequestFinish callback. The SDK retains the ownership of the request and
* error parameters. Do not use them after this functions returns.
* The api object is the one created by the application, it will be valid until the application deletes it.
*
* @param api
* API that started the request.
* @param request
* Information about the request.
* @param e
* Error Information.
* @see MegaRequestListenerInterface#onRequestTemporaryError(MegaApiJava api, MegaRequest request, MegaError e)
* @see MegaRequestListener#onRequestTemporaryError(MegaApi api, MegaRequest request, MegaError error)
*/
@Override
public void onRequestTemporaryError(MegaChatApi api, MegaChatRequest request, MegaChatError e) {
if (listener != null) {
final MegaChatRequest megaRequest = request.copy();
final MegaChatError megaError = e.copy();
megaChatApi.runCallback(new Runnable() {
public void run() {
listener.onRequestTemporaryError(megaChatApi, megaRequest, megaError);
}
});
}
}
}
Loading

0 comments on commit 35ff258

Please sign in to comment.