bool Folder::init() { Account *account = AccountManager::instance()->account(); if (!account) { // Normaly this should not happen, but it could be that there is something // wrong with the config and it is better not to crash. qWarning() << "WRN: No account configured, can't sync"; return false; } // We need to reconstruct the url because the path need to be fully decoded, as csync will re-encode the path: // Remember that csync will just append the filename to the path and pass it to the vio plugin. // csync_owncloud will then re-encode everything. #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QUrl url = remoteUrl(); QString url_string = url.scheme() + QLatin1String("://") + url.authority(QUrl::EncodeDelimiters) + url.path(QUrl::FullyDecoded); #else // Qt4 was broken anyway as it did not encode the '#' as it should have done (it was actually a provlem when parsing the path from QUrl::setPath QString url_string = remoteUrl().toString(); #endif url_string = Utility::toCSyncScheme(url_string); QString localpath = path(); if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url_string.toUtf8().data() ) < 0 ) { qDebug() << "Unable to create csync-context!"; slotSyncError(tr("Unable to create csync-context")); _csync_ctx = 0; } else { csync_set_log_callback( csyncLogCatcher ); csync_set_log_level( 11 ); if (Account *account = AccountManager::instance()->account()) { account->credentials()->syncContextPreInit(_csync_ctx); } else { qDebug() << Q_FUNC_INFO << "No default Account object, huh?"; } if( csync_init( _csync_ctx ) < 0 ) { qDebug() << "Could not initialize csync!" << csync_get_status(_csync_ctx) << csync_get_status_string(_csync_ctx); QString errStr = SyncEngine::csyncErrorToString(CSYNC_STATUS(csync_get_status(_csync_ctx))); const char *errMsg = csync_get_status_string(_csync_ctx); if( errMsg ) { errStr += QLatin1String("<br/>"); errStr += QString::fromUtf8(errMsg); } slotSyncError(errStr); csync_destroy(_csync_ctx); _csync_ctx = 0; } } return _csync_ctx; }
bool Folder::init() { // We need to reconstruct the url because the path needs to be fully decoded, as csync will re-encode the path: // Remember that csync will just append the filename to the path and pass it to the vio plugin. // csync_owncloud will then re-encode everything. #if QT_VERSION >= QT_VERSION_CHECK(5, 0, 0) QUrl url = remoteUrl(); QString url_string = url.scheme() + QLatin1String("://") + url.authority(QUrl::EncodeDelimiters) + url.path(QUrl::FullyDecoded); #else // Qt4 was broken anyway as it did not encode the '#' as it should have done (it was actually a problem when parsing the path from QUrl::setPath QString url_string = remoteUrl().toString(); #endif url_string = Utility::toCSyncScheme(url_string); QString localpath = path(); if( csync_create( &_csync_ctx, localpath.toUtf8().data(), url_string.toUtf8().data() ) < 0 ) { qDebug() << "Unable to create csync-context!"; slotSyncError(tr("Unable to create csync-context")); _csync_ctx = 0; } else { csync_set_log_callback( csyncLogCatcher ); csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 ); Q_ASSERT( _accountState ); if( csync_init( _csync_ctx ) < 0 ) { qDebug() << "Could not initialize csync!" << csync_get_status(_csync_ctx) << csync_get_status_string(_csync_ctx); QString errStr = SyncEngine::csyncErrorToString(CSYNC_STATUS(csync_get_status(_csync_ctx))); const char *errMsg = csync_get_status_string(_csync_ctx); if( errMsg ) { errStr += QLatin1String("<br/>"); errStr += QString::fromUtf8(errMsg); } slotSyncError(errStr); csync_destroy(_csync_ctx); _csync_ctx = 0; } } return _csync_ctx; }
bool RpcAdaptor::remoteCall(const QByteArray &method, const QList<QVariant> &args) { /*QVariantMap msg; msg["method"] = method; msg["params"] = args; msg["sender"] = path(); msg["target"] = remotePath; sendMessage(msg);*/ connection()->remoteCall(remoteUrl(), method, args, path()); return true; }
QVariant RemoteModel::data(const QModelIndex &index, int role) const { const int row = index.row(); switch (role) { case Qt::DisplayRole: case Qt::EditRole: if (index.column() == 0) return remoteName(row); else return remoteUrl(row); default: break; } return QVariant(); }
bool RemoteModel::setData(const QModelIndex &index, const QVariant &value, int role) { if (role != Qt::EditRole) return false; const QString name = remoteName(index.row()); const QString url = remoteUrl(index.row()); switch (index.column()) { case 0: if (name == value.toString()) return true; return renameRemote(name, value.toString()); case 1: if (url == value.toString()) return true; return updateUrl(name, value.toString()); default: return false; } }
bool ACDCallManager::validateTransferToLine(SIPX_CALLSTATE_INFO* pCallInfo) { SIPX_CALL hAssociatedCallHandle; int callEvent; int callCause; const char* remUri; char userUri[512]; mLock.acquire(); // Extract the call handle and state info hAssociatedCallHandle = pCallInfo->hAssociatedCall; callEvent = pCallInfo->event; callCause = pCallInfo->cause; remUri = pCallInfo->remoteAddress; UtlString userId, hostAddress; Url remoteUrl(remUri); remoteUrl.getUserId(userId); remoteUrl.getHostAddress(hostAddress); if (remUri) { // Now find out if there is an agent for this remUri sprintf(userUri,"sip:%s@%s",userId.data(),hostAddress.data()); UtlString agentUri(userUri); ACDAgent* pAgentRef = mpAcdServer->getAcdAgentManager()->getAcdAgentReference(agentUri); if ((pAgentRef) && (FALSE == pAgentRef->isFree())) { mLock.release(); return TRUE; } } mLock.release(); return FALSE; }
void ACDCallManager::updateTransferCallState(SIPX_CALLSTATE_INFO* pCallInfo) { SIPX_CALL hCallHandle = SIPX_CALL_NULL; SIPX_CALL hAssociatedCallHandle; int callEvent; int callCause; const char* remUri; char userUri[512]; ACDCall* pCallRef; mLock.acquire(); // Extract the call handle and state info hAssociatedCallHandle = pCallInfo->hAssociatedCall; callEvent = pCallInfo->event; callCause = pCallInfo->cause; remUri = pCallInfo->remoteAddress; /** * For the NEWCALL_TRANSFER event - find the ACDCall object instance * on the basis of the Associated call handle (from the older leg). */ if (pCallInfo->cause == CALLSTATE_NEW_CALL_TRANSFER) { if (TRUE == validateTransferToLine(pCallInfo)) { // Don't allow agents to transfer calls INTO the acd. It screws // things up. The correct behavior would be to move the call // the agent is currently handling into a new queue, but due to // the inability to remove calls from a conference, this just doesn't // work. Hangup on the transfer attempt. Ths should leave // caller and agent connected. OsSysLog::add(FAC_ACD, PRI_WARNING, "ACDCallManager::updateTransferCallState - " "CALLSTATE_OFFERING::%d to the ACD Line REJECTED", pCallInfo->cause); sipxCallReject(pCallInfo->hCall, SIP_BAD_REQUEST_CODE, "Agent Transfer Loop Rejected"); return ; } // not an agent transferring into the acd hCallHandle = hAssociatedCallHandle; UtlInt callKey(hCallHandle); pCallRef = dynamic_cast<ACDCall*>(mAgentCallHandleMap.findValue(&callKey)); } else // not new call transfer { UtlInt searchKey(pCallInfo->hCall); pCallRef = dynamic_cast<ACDCall*>(mTransferCallHandleMap.findValue(&searchKey)); } if (pCallRef != NULL) { if (callCause == CALLSTATE_NEW_CALL_TRANSFER) { addMapTransferAgentCallHandleToCall(pCallInfo->hCall, pCallRef); pCallRef->mFlagTransfer = TRUE; // only set TRUE here. } if ( (callCause == CALLSTATE_REMOTE_OFFERING_NORMAL) && (pCallRef->mFlagTransfer == TRUE)) { UtlString userId, hostAddress; Url remoteUrl(remUri); remoteUrl.getUserId(userId); remoteUrl.getHostAddress(hostAddress); if (remUri) { // Now find the agent for this remUri sprintf(userUri,"sip:%s@%s",userId.data(),hostAddress.data()); UtlString agentUri(userUri); ACDAgent* pAgentRef = mpAcdServer->getAcdAgentManager()->getAcdAgentReference(agentUri); if (!pAgentRef) { OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateTransferCallState - " "Failed to find Agent. This is probably an agent that is not signed in: " "call(%d), TransferAgentCall(%d), agentUri(%s)", pCallRef->getCallHandle(), pCallInfo->hCall, agentUri.data()); // A non registered agent is not yet supported - so do not try ! pAgentRef = mpAcdServer->getAcdAgentManager()->createACDAgent(userUri, "dummy", "", FALSE, FALSE, NULL, TRUE); if (!pAgentRef) { assert(0); } } //set the mhCallHandle of the Agent object pAgentRef->setCallHandle(pCallInfo->hCall); // set the transfer agent object in the call object pCallRef->mpTransferAgent = pAgentRef; OsSysLog::add(FAC_ACD, gACD_DEBUG, "ACDCallManager::updateTransferCallState - " "success in finding Agent: call(%d), TransferAgentCall(%d) AgentUri(%s)", pCallRef->getCallHandle(), pCallInfo->hCall, pAgentRef->getUriString()->data()); } } if ( (callCause == CALLSTATE_REMOTE_OFFERING_NORMAL) && (pCallRef->mFlagTransfer == FALSE)) { ; // do nothing } else { pCallRef->updateState(hCallHandle, callEvent, callCause); } } mLock.release(); return; }
void Folder::startSync(const QStringList &pathList) { Q_ASSERT(_accountState); Q_UNUSED(pathList) if (!_csync_ctx) { // no _csync_ctx yet, initialize it. init(); if (!_csync_ctx) { qDebug() << Q_FUNC_INFO << "init failed."; // the error should already be set QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection); return; } } else if (proxyDirty()) { setProxyDirty(false); } csync_set_log_level( Logger::instance()->isNoop() ? 0 : 11 ); if (isBusy()) { qCritical() << "* ERROR csync is still running and new sync requested."; return; } _errors.clear(); _csyncError = false; _csyncUnavail = false; _timeSinceLastSyncStart.restart(); _syncResult.clearErrors(); _syncResult.setStatus( SyncResult::SyncPrepare ); _syncResult.setSyncFileItemVector(SyncFileItemVector()); emit syncStateChange(); qDebug() << "*** Start syncing " << alias() << " - client version" << qPrintable(Theme::instance()->version()); if (! setIgnoredFiles()) { slotSyncError(tr("Could not read system exclude file")); QMetaObject::invokeMethod(this, "slotSyncFinished", Qt::QueuedConnection); return; } // pass the setting if hidden files are to be ignored, will be read in csync_update _csync_ctx->ignore_hidden_files = _definition.ignoreHiddenFiles; _engine.reset(new SyncEngine( _accountState->account(), _csync_ctx, path(), remoteUrl().path(), remotePath(), &_journal)); qRegisterMetaType<SyncFileItemVector>("SyncFileItemVector"); qRegisterMetaType<SyncFileItem::Direction>("SyncFileItem::Direction"); connect(_engine.data(), SIGNAL(rootEtag(QString)), this, SLOT(etagRetreivedFromSyncEngine(QString))); connect( _engine.data(), SIGNAL(treeWalkResult(const SyncFileItemVector&)), this, SLOT(slotThreadTreeWalkResult(const SyncFileItemVector&)), Qt::QueuedConnection); connect( _engine.data(), SIGNAL(aboutToPropagate(SyncFileItemVector&)), this, SLOT(slotAboutToPropagate(SyncFileItemVector&))); connect(_engine.data(), SIGNAL(started()), SLOT(slotSyncStarted()), Qt::QueuedConnection); connect(_engine.data(), SIGNAL(finished(bool)), SLOT(slotSyncFinished(bool)), Qt::QueuedConnection); connect(_engine.data(), SIGNAL(csyncError(QString)), SLOT(slotSyncError(QString)), Qt::QueuedConnection); connect(_engine.data(), SIGNAL(csyncUnavailable()), SLOT(slotCsyncUnavailable()), Qt::QueuedConnection); //direct connection so the message box is blocking the sync. connect(_engine.data(), SIGNAL(aboutToRemoveAllFiles(SyncFileItem::Direction,bool*)), SLOT(slotAboutToRemoveAllFiles(SyncFileItem::Direction,bool*))); connect(_engine.data(), SIGNAL(folderDiscovered(bool,QString)), this, SLOT(slotFolderDiscovered(bool,QString))); connect(_engine.data(), SIGNAL(transmissionProgress(ProgressInfo)), this, SLOT(slotTransmissionProgress(ProgressInfo))); connect(_engine.data(), SIGNAL(itemCompleted(const SyncFileItem &, const PropagatorJob &)), this, SLOT(slotItemCompleted(const SyncFileItem &, const PropagatorJob &))); connect(_engine.data(), SIGNAL(syncItemDiscovered(const SyncFileItem &)), this, SLOT(slotSyncItemDiscovered(const SyncFileItem &))); connect(_engine.data(), SIGNAL(newBigFolder(QString)), this, SLOT(slotNewBigFolderDiscovered(QString))); setDirtyNetworkLimits(); ConfigFile cfgFile; auto newFolderLimit = cfgFile.newBigFolderSizeLimit(); quint64 limit = newFolderLimit.first ? newFolderLimit.second * 1000 * 1000 : -1; // convert from MB to B _engine->setNewBigFolderSizeLimit(limit); QMetaObject::invokeMethod(_engine.data(), "startSync", Qt::QueuedConnection); // disable events until syncing is done // _watcher->setEventsEnabled(false); emit syncStarted(); }