2014-07-10 16:27:52 +04:00
|
|
|
/*
|
|
|
|
* Copyright (C) by Klaas Freitag <freitag@owncloud.com>
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
2016-10-25 12:00:07 +03:00
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
2014-07-10 16:27:52 +04:00
|
|
|
*
|
|
|
|
* This program 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. See the GNU General Public License
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2014-07-11 02:31:24 +04:00
|
|
|
#include "syncfilestatus.h"
|
2014-07-10 16:27:52 +04:00
|
|
|
|
2014-11-10 00:34:07 +03:00
|
|
|
namespace OCC {
|
2014-07-10 16:27:52 +04:00
|
|
|
SyncFileStatus::SyncFileStatus()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
SyncFileStatus::SyncFileStatus(SyncFileStatusTag tag)
|
|
|
|
: _tag(tag)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
void SyncFileStatus::set(SyncFileStatusTag tag)
|
|
|
|
{
|
|
|
|
_tag = tag;
|
|
|
|
}
|
|
|
|
|
2016-08-04 15:59:46 +03:00
|
|
|
SyncFileStatus::SyncFileStatusTag SyncFileStatus::tag() const
|
2014-07-10 16:27:52 +04:00
|
|
|
{
|
|
|
|
return _tag;
|
|
|
|
}
|
|
|
|
|
2017-07-21 12:28:15 +03:00
|
|
|
void SyncFileStatus::setShared(bool isShared)
|
2014-07-10 16:27:52 +04:00
|
|
|
{
|
2017-07-21 12:28:15 +03:00
|
|
|
_shared = isShared;
|
2014-07-10 16:27:52 +04:00
|
|
|
}
|
|
|
|
|
2017-07-21 12:28:15 +03:00
|
|
|
bool SyncFileStatus::shared() const
|
2014-07-10 16:27:52 +04:00
|
|
|
{
|
2017-07-21 12:28:15 +03:00
|
|
|
return _shared;
|
2014-07-10 16:27:52 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
QString SyncFileStatus::toSocketAPIString() const
|
|
|
|
{
|
|
|
|
QString statusString;
|
2016-04-12 19:27:32 +03:00
|
|
|
bool canBeShared = true;
|
2014-07-10 16:27:52 +04:00
|
|
|
|
|
|
|
switch (_tag) {
|
2016-03-24 20:20:49 +03:00
|
|
|
case StatusNone:
|
2016-04-12 19:27:32 +03:00
|
|
|
statusString = QLatin1String("NOP");
|
|
|
|
canBeShared = false;
|
2014-07-10 16:27:52 +04:00
|
|
|
break;
|
2016-03-24 20:20:49 +03:00
|
|
|
case StatusSync:
|
2014-07-10 16:27:52 +04:00
|
|
|
statusString = QLatin1String("SYNC");
|
|
|
|
break;
|
2016-03-24 19:42:04 +03:00
|
|
|
case StatusWarning:
|
|
|
|
// The protocol says IGNORE, but all implementations show a yellow warning sign.
|
2014-07-10 16:27:52 +04:00
|
|
|
statusString = QLatin1String("IGNORE");
|
|
|
|
break;
|
2016-03-24 20:20:49 +03:00
|
|
|
case StatusUpToDate:
|
2014-07-10 16:27:52 +04:00
|
|
|
statusString = QLatin1String("OK");
|
|
|
|
break;
|
2016-03-24 20:20:49 +03:00
|
|
|
case StatusError:
|
2014-07-10 16:27:52 +04:00
|
|
|
statusString = QLatin1String("ERROR");
|
|
|
|
break;
|
|
|
|
}
|
2017-07-21 12:28:15 +03:00
|
|
|
if (canBeShared && _shared) {
|
2014-07-10 16:27:52 +04:00
|
|
|
statusString += QLatin1String("+SWM");
|
|
|
|
}
|
|
|
|
|
|
|
|
return statusString;
|
|
|
|
}
|
|
|
|
}
|