Skip to content

Commit

Permalink
Merge pull request #1361 from meganz/release/v3.4.7
Browse files Browse the repository at this point in the history
Release/v3.4.7
  • Loading branch information
sergiohs84 authored Feb 15, 2019
2 parents 31196cb + e6be274 commit 84d906d
Show file tree
Hide file tree
Showing 12 changed files with 81 additions and 25 deletions.
5 changes: 5 additions & 0 deletions bindings/ios/MEGANode.h
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,11 @@ typedef NS_ENUM(NSUInteger, MEGANodeChangeType) {
*/
@property (readonly, nonatomic) NSString *publicLink;

/**
* @brief The handle of the owner of the node.
*/
@property (readonly, nonatomic) uint64_t owner;

/**
* @brief Creates a copy of this MEGANode object.
*
Expand Down
4 changes: 4 additions & 0 deletions bindings/ios/MEGANode.mm
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,10 @@ - (MEGANode *)publicNode {
return self.megaNode ? [[MEGANode alloc] initWithMegaNode:self.megaNode->getPublicNode() cMemoryOwn:YES] : nil;
}

- (uint64_t)owner {
return self.megaNode ? self.megaNode->getOwner() : ::mega::INVALID_HANDLE;
}

- (BOOL)isFile {
return self.megaNode ? self.megaNode->isFile() : NO;
}
Expand Down
6 changes: 3 additions & 3 deletions bindings/ios/MEGASdk.h
Original file line number Diff line number Diff line change
Expand Up @@ -6053,7 +6053,7 @@ typedef NS_ENUM(NSUInteger, StorageState) {
* Even if files are allowed to be served by this function, restrictions related to
* other configuration options ([MEGASdk httpServerSetRestrictedMode]) are still applied.
*
* @param YES to allow to server files, NO to forbid it
* @param enable YES to allow to server files, NO to forbid it
*/
- (void)httpServerEnableFileServer:(BOOL)enable;

Expand All @@ -6077,7 +6077,7 @@ typedef NS_ENUM(NSUInteger, StorageState) {
* Even if folders are allowed to be served by this function, restrictions related to
* other configuration options ([MEGASdk httpServerSetRestrictedMode]) are still applied.
*
* @param YES to allow to server folders, NO to forbid it
* @param enable YES to allow to server folders, NO to forbid it
*/
- (void)httpServerEnableFolderServer:(BOOL)enable;

Expand Down Expand Up @@ -6125,7 +6125,7 @@ typedef NS_ENUM(NSUInteger, StorageState) {
* other configuration options ([MEGASdk httpServerEnableFileServer],
* [MEGASdk httpServerEnableFolderServer]) are still applied.
*
* @param Required state for the restricted mode of the HTTP proxy server
* @param mode Required state for the restricted mode of the HTTP proxy server
*/
- (void)httpServerSetRestrictedMode:(NSInteger)mode;

Expand Down
2 changes: 1 addition & 1 deletion bindings/qt/sdk.pri
Original file line number Diff line number Diff line change
Expand Up @@ -370,7 +370,7 @@ win32 {
include/mega/win32/megafs.h \
include/mega/win32/megawaiter.h

SOURCES += bindings/qt/3rdparty/libs/sqlite3.c
SOURCES += $$MEGASDK_BASE_PATH/bindings/qt/3rdparty/libs/sqlite3.c
}

unix {
Expand Down
15 changes: 12 additions & 3 deletions examples/megacli.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2264,12 +2264,12 @@ struct Login
}
else
{
client->login(email.c_str(), pwkey, pin.c_str());
client->login(email.c_str(), pwkey, (!pin.empty()) ? pin.c_str() : NULL);
}
}
else if (version == 2 && !salt.empty())
{
client->login2(email.c_str(), password.c_str(), &salt, pin.c_str());
client->login2(email.c_str(), password.c_str(), &salt, (!pin.empty()) ? pin.c_str() : NULL);
}
else
{
Expand All @@ -2286,7 +2286,16 @@ static void process_line(char* l)
switch (prompt)
{
case LOGINTFA:
client->login(login.email.c_str(), pwkey, l);
if (strlen(l) > 1)
{
login.pin = l;
login.login(client);
}
else
{
cout << endl << "The pin length is invalid, please try to login again." << endl;
}

setprompt(COMMAND);
return;

Expand Down
2 changes: 1 addition & 1 deletion include/mega/mega_ccronexpr.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ typedef struct {
*
* @param expression cron expression as nul-terminated string,
* should be no longer that 256 bytes
* @param pointer to cron expression structure, it's client code responsibility
* @param target to cron expression structure, it's client code responsibility
* to free/destroy it afterwards
* @param error output error message, will be set to string literal
* error message in case of error. Will be set to NULL on success.
Expand Down
2 changes: 1 addition & 1 deletion include/mega/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,5 @@
#define MEGA_MINOR_VERSION 4
#endif
#ifndef MEGA_MICRO_VERSION
#define MEGA_MICRO_VERSION 6
#define MEGA_MICRO_VERSION 7
#endif
2 changes: 2 additions & 0 deletions include/megaapi.h
Original file line number Diff line number Diff line change
Expand Up @@ -1031,6 +1031,8 @@ class MegaNode
virtual std::string getLocalPath();
#endif

virtual MegaHandle getOwner() const;

/**
* @brief Provides a serialization of the MegaNode object
*
Expand Down
5 changes: 3 additions & 2 deletions include/megaapi_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class MegaNodePrivate : public MegaNode, public Cachable
public:
MegaNodePrivate(const char *name, int type, int64_t size, int64_t ctime, int64_t mtime,
MegaHandle nodeMegaHandle, std::string *nodekey, std::string *attrstring, std::string *fileattrstring,
const char *fingerprint, MegaHandle parentHandle = INVALID_HANDLE,
const char *fingerprint, MegaHandle owner, MegaHandle parentHandle = INVALID_HANDLE,
const char *privateauth = NULL, const char *publicauth = NULL, bool isPublic = true,
bool isForeign = false, const char *chatauth = NULL);

Expand Down Expand Up @@ -453,7 +453,7 @@ class MegaNodePrivate : public MegaNode, public Cachable
virtual bool isOutShare();
virtual bool isInShare();
std::string* getSharekey();

virtual MegaHandle getOwner() const;

#ifdef ENABLE_SYNC
virtual bool isSyncDeleted();
Expand Down Expand Up @@ -505,6 +505,7 @@ class MegaNodePrivate : public MegaNode, public Cachable
double latitude;
double longitude;
MegaNodeList *children;
MegaHandle owner;

#ifdef ENABLE_SYNC
bool syncdeleted;
Expand Down
5 changes: 5 additions & 0 deletions src/megaapi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,11 @@ MegaNodeList *MegaNode::getChildren()
return NULL;
}

MegaHandle MegaNode::getOwner() const
{
return INVALID_HANDLE;
}

char *MegaNode::serialize()
{
return NULL;
Expand Down
51 changes: 41 additions & 10 deletions src/megaapi_impl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
namespace mega {

MegaNodePrivate::MegaNodePrivate(const char *name, int type, int64_t size, int64_t ctime, int64_t mtime, uint64_t nodehandle,
string *nodekey, string *attrstring, string *fileattrstring, const char *fingerprint, MegaHandle parentHandle,
string *nodekey, string *attrstring, string *fileattrstring, const char *fingerprint, MegaHandle owner, MegaHandle parentHandle,
const char *privateauth, const char *publicauth, bool ispublic, bool isForeign, const char *chatauth)
: MegaNode()
{
Expand Down Expand Up @@ -104,6 +104,7 @@ MegaNodePrivate::MegaNodePrivate(const char *name, int type, int64_t size, int64
this->sharekey = NULL;
this->foreign = isForeign;
this->children = NULL;
this->owner = owner;

if (privateauth)
{
Expand Down Expand Up @@ -179,6 +180,7 @@ MegaNodePrivate::MegaNodePrivate(MegaNode *node)
this->foreign = node->isForeign();
this->sharekey = NULL;
this->children = NULL;
this->owner = node->getOwner();

if (node->isExported())
{
Expand Down Expand Up @@ -336,6 +338,7 @@ MegaNodePrivate::MegaNodePrivate(Node *node)
this->mtime = node->mtime;
this->nodehandle = node->nodehandle;
this->parenthandle = node->parent ? node->parent->nodehandle : INVALID_HANDLE;
this->owner = node->owner;

if(node->attrstring)
{
Expand Down Expand Up @@ -490,7 +493,10 @@ bool MegaNodePrivate::serialize(string *d)
char hasChatAuth = (chatAuth && chatAuth[0]) ? 1 : 0;
d->append((char *)&hasChatAuth, 1);

d->append("\0\0\0\0\0\0", 7);
char hasOwner = 1;
d->append((char *)&hasOwner, 1);

d->append("\0\0\0\0\0", 6);

if (hasChatAuth)
{
Expand All @@ -499,6 +505,8 @@ bool MegaNodePrivate::serialize(string *d)
d->append(chatAuth, ll);
}

d->append((char *)&owner, sizeof(handle));

return true;
}

Expand Down Expand Up @@ -615,12 +623,15 @@ MegaNodePrivate *MegaNodePrivate::unserialize(string *d)
char hasChatAuth = MemAccess::get<char>(ptr);
ptr += sizeof(char);

if (memcmp(ptr, "\0\0\0\0\0\0", 7))
char hasOwner = MemAccess::get<handle>(ptr);
ptr += sizeof(char);

if (memcmp(ptr, "\0\0\0\0\0", 6))
{
LOG_err << "MegaNodePrivate unserialization failed - invalid version";
return NULL;
}
ptr += 7;
ptr += 6;

string chatauth;
if (hasChatAuth)
Expand All @@ -646,11 +657,26 @@ MegaNodePrivate *MegaNodePrivate::unserialize(string *d)
}
}

handle owner = INVALID_HANDLE;
if (hasOwner)
{
if (ptr + sizeof(handle) <= end)
{
owner = MemAccess::get<handle>(ptr);
ptr += sizeof(handle);
}
else
{
LOG_err << "MegaNodePrivate unserialization failed - owner not found";
return NULL;
}
}

d->erase(0, ptr - d->data());

return new MegaNodePrivate(namelen ? name.c_str() : NULL, FILENODE, size, ctime,
mtime, nodehandle, &nodekey, &attrstring, &fileattrstring,
fingerprintlen ? fingerprint.c_str() : NULL,
fingerprintlen ? fingerprint.c_str() : NULL, owner,
parenthandle, privauth.c_str(), pubauth.c_str(),
isPublicNode, foreign, hasChatAuth ? chatauth.c_str() : NULL);
}
Expand Down Expand Up @@ -1007,6 +1033,10 @@ int MegaNodePrivate::getChanges()
return changed;
}

MegaHandle MegaNodePrivate::getOwner() const
{
return owner;
}

const unsigned int MegaApiImpl::MAX_SESSION_LENGTH = 64;

Expand Down Expand Up @@ -9589,16 +9619,16 @@ MegaNode *MegaApiImpl::createForeignFileNode(MegaHandle handle, const char *key,
string fileattrsting;
nodekey.resize(strlen(key) * 3 / 4 + 3);
nodekey.resize(Base64::atob(key, (byte *)nodekey.data(), int(nodekey.size())));
return new MegaNodePrivate(name, FILENODE, size, mtime, mtime, handle, &nodekey, &attrstring, &fileattrsting, NULL, parentHandle,
privateauth, publicauth, false, true);
return new MegaNodePrivate(name, FILENODE, size, mtime, mtime, handle, &nodekey, &attrstring, &fileattrsting, NULL, INVALID_HANDLE,
parentHandle, privateauth, publicauth, false, true);
}

MegaNode *MegaApiImpl::createForeignFolderNode(MegaHandle handle, const char *name, MegaHandle parentHandle, const char *privateauth, const char *publicauth)
{
string nodekey;
string attrstring;
string fileattrsting;
return new MegaNodePrivate(name, FOLDERNODE, 0, 0, 0, handle, &nodekey, &attrstring, &fileattrsting, NULL, parentHandle,
return new MegaNodePrivate(name, FOLDERNODE, 0, 0, 0, handle, &nodekey, &attrstring, &fileattrsting, NULL, INVALID_HANDLE, parentHandle,
privateauth, publicauth, false, true);
}

Expand Down Expand Up @@ -25994,8 +26024,8 @@ void MegaHTTPContext::onRequestFinish(MegaApi *, MegaRequest *request, MegaError

/**
* Gets permissions string: e.g: 777 -> rwxrwxrwx
* @param perm numeric permissions
* @param str_perm out permission string buffer
* @param permissions permissions
* @param permsString permission string buffer
*/
void MegaFTPServer::getPermissionsString(int permissions, char *permsString)
{
Expand Down Expand Up @@ -29378,3 +29408,4 @@ int MegaTimeZoneDetailsPrivate::getDefault() const
}

}

7 changes: 3 additions & 4 deletions src/megaclient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8522,11 +8522,11 @@ error MegaClient::removecontact(const char* email, visibility_t show)
* "+" - Public and plain text, accessible by anyone knowing userhandle
* "^" - Private and non-encrypted.
*
* @param an Attribute name.
* @param at Attribute name.
* @param av Attribute value.
* @param avl Attribute value length.
* @param ctag Tag to identify the request at intermediate layer
* @return Void.

*/
void MegaClient::putua(attr_t at, const byte* av, unsigned avl, int ctag)
{
Expand Down Expand Up @@ -8614,9 +8614,8 @@ void MegaClient::putua(userattr_map *attrs, int ctag)
* @brief Queue a user attribute retrieval.
*
* @param u User.
* @param an Attribute name.
* @param at Attribute name.
* @param ctag Tag to identify the request at intermediate layer
* @return Void.
*/
void MegaClient::getua(User* u, const attr_t at, int ctag)
{
Expand Down

0 comments on commit 84d906d

Please sign in to comment.