1 /*
2  * (c) 2013-2015 by Mega Limited, Auckland, New Zealand
3  *
4  * This file is part of the MEGA SDK - Client Access Engine.
5  *
6  * Applications using the MEGA API must present a valid application key
7  * and comply with the the rules set forth in the Terms of Service.
8  *
9  * The MEGA SDK is distributed in the hope that it will be useful,\
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
12  * @copyright Simplified (2-clause) BSD License.
13  * You should have received a copy of the license along with this
14  * program.
15  */
16 package nz.mega.sdk;
17 
18 import java.util.ArrayList;
19 
20 /**
21  * Interface to get information about global events.
22  * <p>
23  * You can implement this interface and start receiving events calling MegaApiJava.addGlobalListener().
24  * MegaListener objects can also receive global events.
25  */
26 public interface MegaGlobalListenerInterface {
27     /**
28      * This function is called when there are new or updated contacts in the account.
29      * <p>
30      * The SDK retains the ownership of the MegaUserList in the second parameter.
31      * The list and all the MegaUser objects that it contains will be valid until this function returns.
32      * If you want to save the list, use MegaUserList.copy().
33      * If you want to save only some of the MegaUser objects, use MegaUser.copy() for those objects.
34      * @param api
35      *          Mega Java API connected to account.
36      * @param users
37      *          List of new or updated Contacts.
38      */
onUsersUpdate(MegaApiJava api, ArrayList<MegaUser> users)39     public void onUsersUpdate(MegaApiJava api, ArrayList<MegaUser> users);
40 
41     /**
42      * This function is called when there are new or updated user alerts in the account
43      *
44      * The SDK retains the ownership of the MegaUserAlertList in the second parameter. The list and all the
45      * MegaUserAlert objects that it contains will be valid until this function returns. If you want to save the
46      * list, use MegaUserAlertList::copy. If you want to save only some of the MegaUserAlert objects, use MegaUserAlert::copy
47      * for those objects.
48      *
49      * @param api MegaApi object connected to the account
50      * @param userAlertList List that contains the new or updated contacts
51      */
onUserAlertsUpdate(MegaApiJava api, ArrayList<MegaUserAlert> userAlerts)52     public void onUserAlertsUpdate(MegaApiJava api, ArrayList<MegaUserAlert> userAlerts);
53 
54     /**
55      * This function is called when there are new or updated nodes in the account.
56      * <p>
57      * When the full account is reloaded or a large number of server notifications arrives at once,
58      * the second parameter will be null.
59      * The SDK retains the ownership of the MegaNodeList in the second parameter.
60      * The list and all the MegaNode objects that it contains will be valid until this function returns.
61      * If you want to save the list, use MegaNodeList.copy().
62      * If you want to save only some of the MegaNode objects, use MegaNode.copy() for those nodes.
63      *
64      * @param api
65      *            API connected to account.
66      * @param nodeList
67      *            List of new or updated Nodes.
68      */
onNodesUpdate(MegaApiJava api, ArrayList<MegaNode> nodeList)69     public void onNodesUpdate(MegaApiJava api, ArrayList<MegaNode> nodeList);
70 
71     /**
72      * This function is called when an inconsistency is detected in the local cache.
73      * <p>
74      * You should call MegaApi.fetchNodes() when this callback is received.
75      *
76      * @param api
77      *            API connected to account.
78      */
onReloadNeeded(MegaApiJava api)79     public void onReloadNeeded(MegaApiJava api);
80 
81     /**
82      * This function is called when the account has been updated (confirmed/upgraded/downgraded)
83      *
84      * The usage of this callback to handle the external account confirmation is deprecated.
85      * Instead, you should use MegaGlobalListener::onEvent.
86      *
87      * @param api MegaApi object connected to the account
88      */
onAccountUpdate(MegaApiJava api)89     public void onAccountUpdate(MegaApiJava api);
90 
91     /**
92      * This function is called when there are new or updated contact requests in the account
93      *
94      * When the full account is reloaded or a large number of server notifications arrives at once, the
95      * second parameter will be NULL.
96      *
97      * The SDK retains the ownership of the MegaContactRequestList in the second parameter. The list and all the
98      * MegaContactRequest objects that it contains will be valid until this function returns. If you want to save the
99      * list, use MegaContactRequestList::copy. If you want to save only some of the MegaContactRequest objects, use MegaContactRequest::copy
100      * for them.
101      *
102      * @param api MegaApi object connected to the account
103      * @param requests List that contains the new or updated contact requests
104      */
onContactRequestsUpdate(MegaApiJava api, ArrayList<MegaContactRequest> requests)105     public void onContactRequestsUpdate(MegaApiJava api, ArrayList<MegaContactRequest> requests);
106 
107     /**
108      * The details about the event, like the type of event and optionally any
109      * additional parameter, is received in the \c params parameter.
110      *
111      * You can check the type of event by calling MegaEvent::getType
112      *
113      * The SDK retains the ownership of the details of the event (\c event).
114      * Don't use them after this functions returns.
115      *
116      * Currently, the following type of events are notified:
117      *
118      *  - MegaEvent::EVENT_COMMIT_DB: when the SDK commits the ongoing DB transaction.
119      *  This event can be used to keep synchronization between the SDK cache and the
120      *  cache managed by the app thanks to the sequence number.
121      *
122      *  Valid data in the MegaEvent object received in the callback:
123      *      - MegaEvent::getText: sequence number recorded by the SDK when this event happened
124      *
125      *  - MegaEvent::EVENT_ACCOUNT_CONFIRMATION: when a new account is finally confirmed
126      * by the user by confirming the signup link.
127      *
128      *   Valid data in the MegaEvent object received in the callback:
129      *      - MegaEvent::getText: email address used to confirm the account
130      *
131      *  - MegaEvent::EVENT_CHANGE_TO_HTTPS: when the SDK automatically starts using HTTPS for all
132      * its communications. This happens when the SDK is able to detect that MEGA servers can't be
133      * reached using HTTP or that HTTP communications are being tampered. Transfers of files and
134      * file attributes (thumbnails and previews) use HTTP by default to save CPU usage. Since all data
135      * is already end-to-end encrypted, it's only needed to use HTTPS if HTTP doesn't work. Anyway,
136      * applications can force the SDK to always use HTTPS using MegaApi::useHttpsOnly. It's recommended
137      * that applications that receive one of these events save that information on its settings and
138      * automatically enable HTTPS on next executions of the app to not force the SDK to detect the problem
139      * and automatically switch to HTTPS every time that the application starts.
140      *
141      *  - MegaEvent::EVENT_DISCONNECT: when the SDK performs a disconnect to reset all the
142      * existing open-connections, since they have become unusable. It's recommended that the app
143      * receiving this event reset its connections with other servers, since the disconnect
144      * performed by the SDK is due to a network change or IP addresses becoming invalid.
145      *
146      *  - MegaEvent::EVENT_ACCOUNT_BLOCKED: when the account get blocked, typically because of
147      * infringement of the Mega's terms of service repeatedly. This event is followed by an automatic
148      * logout.
149      *
150      *  Valid data in the MegaEvent object received in the callback:
151      *      - MegaEvent::getText: message to show to the user.
152      *      - MegaEvent::getNumber: code representing the reason for being blocked.
153      *          200: suspension message for any type of suspension, but copyright suspension.
154      *          300: suspension only for multiple copyright violations.
155      *          400: the subuser account has been disabled.
156      *          401: the subuser account has been removed.
157      *          500: The account needs to be verified by an SMS code.
158      *          700: the account is supended for Weak Account Protection.
159      *
160      * - MegaEvent::EVENT_STORAGE: when the status of the storage changes.
161      *
162      * For this event type, MegaEvent::getNumber provides the current status of the storage
163      *
164      * There are three possible storage states:
165      *     - MegaApi::STORAGE_STATE_GREEN = 0
166      *     There are no storage problems
167      *
168      *     - MegaApi::STORAGE_STATE_ORANGE = 1
169      *     The account is almost full
170      *
171      *     - MegaApi::STORAGE_STATE_RED = 2
172      *     The account is full. Uploads have been stopped
173      *
174      *     - MegaApi::STORAGE_STATE_CHANGE = 3
175      *     There is a possible significant change in the storage state.
176      *     It's needed to call MegaApi::getAccountDetails to check the storage status.
177      *     After calling it, this callback will be called again with the corresponding
178      *     state if there is really a change.
179      *
180      *     - MegaApi::STORAGE_STATE_PAYWALL = 4
181      *     The account has been full for a long time. Now most of actions are disallowed.
182      *     It's needed to call MegaApi::getUserData in order to retrieve the deadline/warnings
183      *     timestamps. @see MegaApi::getOverquotaDeadlineTs and MegaApi::getOverquotaWarningsTs.
184      *
185      * - MegaEvent::EVENT_NODES_CURRENT: when all external changes have been received
186      *
187      * - MegaEvent::EVENT_MEDIA_INFO_READY: when codec-mappings have been received
188      *
189      * - MegaEvent::EVENT_STORAGE_SUM_CHANGED: when the storage sum has changed.
190      *
191      * For this event type, MegaEvent::getNumber provides the new storage sum.
192      *
193      * - MegaEvent::EVENT_BUSINESS_STATUS: when the status of a business account has changed.
194      *
195      * For this event type, MegaEvent::getNumber provides the new business status.
196      *
197      * The posible values are:
198      *  - BUSINESS_STATUS_EXPIRED = -1
199      *  - BUSINESS_STATUS_INACTIVE = 0
200      *  - BUSINESS_STATUS_ACTIVE = 1
201      *  - BUSINESS_STATUS_GRACE_PERIOD = 2
202      *
203      * - MegaEvent::EVENT_KEY_MODIFIED: when the key of a user has changed.
204      *
205      * For this event type, MegaEvent::getHandle provides the handle of the user whose key has been modified.
206      * For this event type, MegaEvent::getNumber provides type of key that has been modified.
207      *
208      * The possible values are:
209      *  - Public chat key (Cu25519)     = 0
210      *  - Public signing key (Ed25519)  = 1
211      *  - Public RSA key                = 2
212      *  - Signature of chat key         = 3
213      *  - Signature of RSA key          = 4
214      *
215      * - MegaEvent::EVENT_GLOBAL_FLAGS_READY: when the global flags are available/updated.
216      *
217      * @param api MegaApi object connected to the account
218      * @param event Details about the event
219      */
onEvent(MegaApiJava api, MegaEvent event)220     public void onEvent(MegaApiJava api, MegaEvent event);
221 }
222