void FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) { qDebug() << Q_FUNC_INFO; QVariant inputData = pushData.infoPair.second; switch ( pushData.type ) { case Tomahawk::InfoSystem::InfoTrackUnresolved: notifyUser( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." ); return; case Tomahawk::InfoSystem::InfoNotifyUser: notifyUser( pushData.infoPair.second.toString() ); return; case Tomahawk::InfoSystem::InfoNowStopped: notifyUser( "Tomahawk is stopped." ); return; case Tomahawk::InfoSystem::InfoNowPlaying: nowPlaying( pushData.infoPair.second ); return; default: return; } }
void SnoreNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "showing notification:" << TomahawkSettings::instance()->songChangeNotificationEnabled(); if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() ) return; switch ( pushData.type ) { case Tomahawk::InfoSystem::InfoTrackUnresolved: notifyUser( Tomahawk::InfoSystem::InfoTrackUnresolved, tr( "The current track could not be resolved. %applicationName will pick back up with the next resolvable track from this source." ), m_defaultIcon ); return; case Tomahawk::InfoSystem::InfoNotifyUser: notifyUser( Tomahawk::InfoSystem::InfoNotifyUser,pushData.infoPair.second.toString(), m_defaultIcon ); return; case Tomahawk::InfoSystem::InfoNowStopped: notifyUser( Tomahawk::InfoSystem::InfoNowStopped, tr( "%applicationName stopped playback." ), m_defaultIcon ); return; case Tomahawk::InfoSystem::InfoNowPlaying: nowPlaying( pushData.infoPair.second ); return; case Tomahawk::InfoSystem::InfoInboxReceived: inboxReceived( pushData.infoPair.second ); return; default: return; } }
void FdoNotifyPlugin::pushInfo( Tomahawk::InfoSystem::InfoPushData pushData ) { qDebug() << Q_FUNC_INFO << "showing notification: " << TomahawkSettings::instance()->songChangeNotificationEnabled(); if ( !TomahawkSettings::instance()->songChangeNotificationEnabled() ) return; QVariant inputData = pushData.infoPair.second; switch ( pushData.type ) { case Tomahawk::InfoSystem::InfoTrackUnresolved: notifyUser( "The current track could not be resolved. Tomahawk will pick back up with the next resolvable track from this source." ); return; case Tomahawk::InfoSystem::InfoNotifyUser: notifyUser( pushData.infoPair.second.toString() ); return; case Tomahawk::InfoSystem::InfoNowStopped: notifyUser( "Tomahawk is stopped." ); return; case Tomahawk::InfoSystem::InfoNowPlaying: nowPlaying( pushData.infoPair.second ); return; default: return; } }
//Returns True, if input data value is set for an index //Returns False, if input data value is not set bool MatrixModel::setData(const QModelIndex & index, const QVariant & value, int role) { if (role == Qt::EditRole && !_enableComparison) { bool ok; QString valueInStr = value.toString(); valueInStr.toDouble(&ok); if (!ok) { emit notifyUser("[MatrixModel::setData] Error: Only double Precision Numbers allowed"); return false; } //save value from editor to member m_gridData m_gridData[index.row()][index.column()] = valueInStr.toUtf8(); // Set bit for edited data at given Index changedData[index.row()+currentMinRow][index.column()]= true; editedGridData[QPair<int,int>(index.row()+currentMinRow,index.column())] = valueInStr.toUtf8(); for (int row= 0; row < _rows; row++) { diffData[row].fill(false); } } return true; }
void YaDiskRVFSDriver::connectHandlerStage2(RESULT error, PluginSettings pluginSettings) { if(error == eNO_ERROR && m_state == eAuthInProgress) { GeneralSettings generalSettings; WebMounter::getSettingStorage()->getData(generalSettings); WebMounter::getSettingStorage()->addSettings(pluginSettings); m_httpConnector->setSettings( pluginSettings.m_userName , pluginSettings.m_userPassword , generalSettings.m_proxyAddress , generalSettings.m_proxyLogin + ":" + generalSettings.m_proxyPassword , pluginSettings.m_isOAuthUsing , pluginSettings.m_oAuthToken ); if(m_state != eSyncStopping) { updateState(100, eAuthorized); } start(); // run sync thread } else { updateState(100, eNotConnected); notifyUser(Ui::Notification::eCRITICAL, tr("Error"), tr("Authorization failed !\n" "Please check proxy settings on Configuration tab and check settings on corresponding plugin tab...\n")); } }
RESULT YaDiskRVFSDriver::uploadFile(const QString& path, const QString& title, const QString& /*Id*/, const QString& parentId) { QString xmlResp; QString id = ROOT_ID; QFileInfo fInfo(path); if (fInfo.size() == 0) { return eNO_ERROR; } RESULT err = m_httpConnector->uploadFile(path, title, parentId, xmlResp); unsigned int retryUploadCounter = 0; while(err != eNO_ERROR && retryUploadCounter < MAX_UPLOAD_RETRY) { err = m_httpConnector->uploadFile(path, title, parentId, xmlResp); retryUploadCounter++; } VFSElement elem; if(!err) { QFileInfo fInfo(path); id = fInfo.fileName(); VFSCache* vfsCache = WebMounter::getCache(); elem = VFSElement(VFSElement::FILE , fInfo.absoluteFilePath() , title , "" , "" , id , id , parentId , "" , m_pluginName); vfsCache->insert(elem); QFile::Permissions permissions = QFile::permissions(elem.getPath()); permissions &= ~(QFile::WriteGroup|QFile::WriteOwner|QFile::WriteUser|QFile::WriteOther); QFile::setPermissions(elem.getPath(), permissions); } else { notifyUser(Ui::Notification::eCRITICAL , tr("Error") , tr("File upload failed (") + elem.getName() + QString(")")); } WebMounter::getProxy()->fileUploaded(fInfo.absoluteFilePath(), err); return err; }
bool NetworkManager::startListening() { if (m_server == NULL) { m_server = new QTcpServer(this); connect(m_server, SIGNAL(newConnection()), this, SLOT(nouveauClientConnecte())); } if (m_server->listen(QHostAddress::Any, m_configDialog->getPort())) { emit notifyUser(tr("Server is on.")); connect(this, SIGNAL(linkDeleted(NetworkLink *)), m_playersList, SLOT(delPlayerWithLink(NetworkLink *))); return true; }
QGestureRecognizer::Result LoopRecognizer::handleCursorMove (LoopGesture *gesture, QPointF scenePoint) { GEUZEN_PRETTY_DEBUG << gesture << scenePoint; if (gesture == 0) { return QGestureRecognizer::Ignore; } if (!(user && user->contains(user->mapFromScene(scenePoint)))) { return QGestureRecognizer::Ignore; // not our point } QPointF last = gesture->lastPos; gesture->lastPos = scenePoint; if (!gesture->haveStarted) { gesture->reset (); gesture->haveStarted = true; gesture->setHotSpot (scenePoint); GEUZEN_PRETTY_DEBUG << " ____maybbe " << gesture << gesture->state(); return QGestureRecognizer::Ignore; } quint8 leftRight (0); quint8 upDown (0); leftRight = last.x() < scenePoint.x() ? 1 : last.x() > scenePoint.x() ? 0xff : 0; upDown = last.y() < scenePoint.y() ? 0x1 : last.y() > scenePoint.y() ? 0xff : 0; quint32 segment = (upDown << 8) | leftRight; qDebug () << hex << " new seg " << segment << dec; if (leftRight != 0 && upDown != 0) { if (gesture->sequence.isEmpty() || gesture->sequence.last() != segment) { gesture-> sequence.append (segment); } } qDebug () << hex << gesture->sequence << dec; if (chopTailCircle(gesture->sequence)) { qDebug () << " detected CIRCLE"; gesture->sequence.clear(); GEUZEN_PRETTY_DEBUG << " fer SURE " << gesture << gesture->state(); notifyUser(); } return QGestureRecognizer::Ignore; }
void SnoreNotifyPlugin::nowPlaying( const QVariant& input ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO; if ( !input.canConvert< QVariantMap >() ) return; QVariantMap map = input.toMap(); if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) return; InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >(); if ( !hash.contains( "title" ) || !hash.contains( "artist" ) || !hash.contains( "album" ) ) return; QString messageText; // If the window manager supports notification styling then use it. // Remark: If using xml-based markup in notifications, the supplied strings need to be escaped. QString album; if ( !hash[ "album" ].isEmpty() ) album = QString( "<br><i>%1</i> %2" ).arg( tr( "on", "'on' is followed by an album name" ) ).arg( hash[ "album" ].toHtmlEscaped() ); messageText = tr( "%1%4 %2%3.", "%1 is a title, %2 is an artist and %3 is replaced by either the previous message or nothing, %4 is the preposition used to link track and artist ('by' in english)" ) .arg( hash[ "title" ].toHtmlEscaped() ) .arg( hash[ "artist" ].toHtmlEscaped() ) .arg( album ) .arg( QString( "<br><i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) ); // Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text messageText = QString( "<i></i>%1" ).arg( messageText ); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << "sending message" << messageText; // If there is a cover availble use it, else use Tomahawk logo as default. Snore::Icon image = m_defaultIcon; if ( map.contains( "cover" ) && map[ "cover" ].canConvert< QImage >() ) { image = Snore::Icon( QPixmap::fromImage( map[ "cover" ].value< QImage >() ) ); tDebug( LOGVERBOSE ) << Q_FUNC_INFO << image; } notifyUser( InfoNowPlaying, messageText, image ); }
void YandexNarodRVFSDriver::connectHandler(PluginSettings& pluginSettings) { QMutexLocker locker(&m_driverMutex); if(m_state == RemoteDriver::eNotConnected) { GeneralSettings generalSettings; WebMounter::getSettingStorage()->getData(generalSettings); WebMounter::getSettingStorage()->addSettings(pluginSettings); m_httpConnector->setSettings( pluginSettings.m_userName , pluginSettings.m_userPassword , generalSettings.m_proxyAddress , generalSettings.m_proxyLogin + ":" + generalSettings.m_proxyPassword ); if(m_state != eSyncStopping) { updateState(0, eAuthInProgress); } if(m_httpConnector->auth() == eNO_ERROR) { if(m_state != eSyncStopping) { updateState(100, eAuthorized); } start(); // run sync thread } else { updateState(100, eNotConnected); notifyUser(Ui::Notification::eCRITICAL, tr("Error"), tr("Authorization failed !\n" "Please check proxy settings on Configuration tab and check settings on corresponding plugin tab...\n")); } } }
// This slot is connected to a signal in each Backend object, // so we know when we're done syncing and can let the user // interact with the application again void MainWindow::bugsUpdated() { mSyncRequests--; qDebug() << "bugsUpdated: mSyncRequests is now: " << mSyncRequests; if (mSyncRequests == 0) { if (mSyncPosition == mBackendList.size()) { filterTable(); mUploading = false; stopAnimation(); notifyUser(); emit reloadFromDatabase(); } else { syncNextTracker(); } } }
void SnoreNotifyPlugin::inboxReceived( const QVariant& input ) { tDebug( LOGVERBOSE ) << Q_FUNC_INFO; if ( !input.canConvert< QVariantMap >() ) return; QVariantMap map = input.toMap(); if ( !map.contains( "trackinfo" ) || !map[ "trackinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) return; if ( !map.contains( "sourceinfo" ) || !map[ "sourceinfo" ].canConvert< Tomahawk::InfoSystem::InfoStringHash >() ) return; InfoStringHash hash = map[ "trackinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >(); if ( !hash.contains( "title" ) || !hash.contains( "artist" ) ) return; InfoStringHash src = map[ "sourceinfo" ].value< Tomahawk::InfoSystem::InfoStringHash >(); if ( !src.contains( "friendlyname" ) ) return; QString messageText; // Remark: If using xml-based markup in notifications, the supplied strings need to be escaped. messageText = tr( "%1 sent you\n%2%4 %3.", "%1 is a nickname, %2 is a title, %3 is an artist, %4 is the preposition used to link track and artist ('by' in english)" ) .arg( src["friendlyname"].toHtmlEscaped() ) .arg( hash[ "title" ].toHtmlEscaped() ) .arg( hash[ "artist" ].toHtmlEscaped() ) .arg( QString( "\n<i>%1</i>" ).arg( tr( "by", "preposition to link track and artist" ) ) ); // Dirty hack(TM) so that KNotify/QLabel recognizes the message as Rich Text messageText = QString( "<i></i>%1" ).arg( messageText ); Snore::Icon icon( RESPATH "images/inbox-512x512.png" ); notifyUser( Tomahawk::InfoSystem::InfoInboxReceived, messageText, icon ); }
gboolean refreshStats(GList *hosts) { GList *ho; gboolean r = TRUE; static gboolean upd_pending = FALSE; gboolean n_upd_pending = FALSE; ho = g_list_first(hosts); #ifdef FEAT_AUTOREF static gboolean do_autoref = TRUE; gint num_in_refresh = 0; #endif while(ho) { HostNode *n = (HostNode *) ho->data; if(screen_get_sessions(n)) { if(n->category != C_SESSIONS) { n->category = C_SESSIONS; rebuilddl = TRUE; } } else { if(n->category == C_UPDATES_PENDING) n_upd_pending = TRUE; if (n->category == C_SESSIONS) n->category = C_REFRESH_REQUIRED; if(n->category == C_REFRESH_REQUIRED) { /* Try to get a lock for the host. */ gint rsetlck = setLockForHost(n); /* We don't got the lock. */ if(rsetlck == -1) { n->status|= HOST_STATUS_LOCKED; freePackages(n); } /* We got the lock. */ else if (rsetlck == 0) { if(n->status & HOST_STATUS_LOCKED) { refreshStatsOfNode(n); /* n->status ^= HOST_STATUS_LOCKED; */ } else { n->category = C_REFRESH; rebuilddl = TRUE; freePackages(n); if(ssh_cmd_refresh(n) == FALSE) { n->category = C_UNKNOWN; } } /* Something weird happend. */ } else { n->category = C_UNKNOWN; rebuilddl = TRUE; } } } #ifdef FEAT_AUTOREF if(n->category == C_REFRESH) num_in_refresh++; #endif ho = g_list_next(ho); } #ifdef FEAT_TCLFILTER applyFilter(hosts); #endif if(n_upd_pending && !upd_pending) notifyUser(); upd_pending = n_upd_pending; #ifdef FEAT_AUTOREF if(cfg->auto_refresh) { if (num_in_refresh == 0) { if(do_autoref) { if (autoref_trigger_auto()) drawStatus (_("Auto refresh triggered..."), FALSE); do_autoref = FALSE; } } else do_autoref = TRUE; } #endif return(r); }
RESULT YandexNarodRVFSDriver::sync() { RESULT res = eERROR_GENERAL; SettingStorage* settings = WebMounter::getSettingStorage(); QString pluginStoragePath = settings->getAppStoragePath() + QString(QDir::separator()) + m_pluginName; QFileInfo fInfo(pluginStoragePath); unsigned int uNotDownloaded = 0; PluginSettings plSettings; settings->getData(plSettings, m_pluginName); m_driverMutex.lock(); if(m_state != eSyncStopping) { updateState(0, RemoteDriver::eSync); } m_driverMutex.unlock(); QList<VFSElement> elements; VFSElement elem = VFSElement(VFSElement::DIRECTORY , fInfo.absoluteFilePath() , "ROOT" , "" , "" , "" , ROOT_ID , ROOT_ID , "" , m_pluginName); elements.append(elem); res = getElements(elements); if(!res) { QDir qDir; QFile qFile; uNotDownloaded = elements.count(); VFSCache* vfsCache = WebMounter::getCache(); VFSCache::iterator iter = vfsCache->begin(); for(iter; iter != vfsCache->end(); ++iter) { if(iter->getPluginName() == m_pluginName) { bool found = false; int count = elements.count(); // Try to find element in new data for(int i=0; i<count; i++) { if(iter->getId() == elements[i].getId()) { found = true; if(iter != elements[i]) { if(iter->getType() == VFSElement::DIRECTORY) { qDir.rename(iter->getPath(), elements[i].getPath()); } break; } elements.removeAt(i); break; } } // Element has been deleted if(!found) { VFSCache::iterator iter1 = iter--; vfsCache->erase(iter1); } } } { LOCK(m_driverMutex); if(m_state != eSyncStopping) { updateState(30, RemoteDriver::eSync); } } // Add newly created elements for(int i=0; i<elements.count(); i++) { vfsCache->insert(elements[i]); } { LOCK(m_driverMutex); if(m_state != eSyncStopping) { updateState(40, RemoteDriver::eSync); } } QString rootPath = WebMounter::getSettingStorage()->getAppStoragePath() + QString(QDir::separator()) + m_pluginName; QFileInfo fInfo(rootPath); syncCacheWithFileSystem(fInfo.absoluteFilePath()); { LOCK(m_driverMutex); if(m_state != eSyncStopping) { updateState(50, RemoteDriver::eSync); } } if(plSettings.m_fullSync) { res = downloadFiles(); } } if(res != eNO_ERROR) { stopPlugin(); notifyUser(Ui::Notification::eCRITICAL, tr("Error"), tr("Sync failed !\n")); //updateState(100, RemoteDriver::eNotConnected); } else { m_driverMutex.lock(); if(m_state != eSyncStopping) { updateState(100, eConnected); } m_driverMutex.unlock(); } return res; }
RESULT YandexNarodRVFSDriver::uploadFile(const QString& path, const QString& title, const QString& /*Id*/, const QString& parentId) { QString xmlResp; QString id = ROOT_ID; QFileInfo fInfo(path); RESULT err = m_httpConnector->uploadFile(path, title, parentId, xmlResp); unsigned int retryUploadCounter = 0; while(err != eNO_ERROR && retryUploadCounter < MAX_UPLOAD_RETRY) { err = m_httpConnector->uploadFile(path, title, parentId, xmlResp); retryUploadCounter++; } VFSElement elem; if(!err && xmlResp != "") { id = RegExp::getByPattern("\"fids\": \"(.*)\"", xmlResp); if(id != "") { // Trying to get new element from server to retrieve the data-token QList<VFSElement> elements; err = getElements(elements); if(err == eNO_ERROR) { int i=0; for(i=0; i<elements.count(); i++) { if(elements[i].getId() == id) break; } QString hash = RegExp::getByPattern("\"hash\": \"(.*)\",", xmlResp); VFSCache* vfsCache = WebMounter::getCache(); elem = VFSElement(VFSElement::FILE , fInfo.absoluteFilePath() , title , "" , (i<elements.count() ? elements[i].getEditMediaUrl() : "") , "http://narod.ru/disk/" + hash + "/" + fInfo.fileName() + ".html" , id , parentId , "" , m_pluginName); vfsCache->insert(elem); QFile::Permissions permissions = QFile::permissions(elem.getPath()); permissions &= ~(QFile::WriteGroup|QFile::WriteOwner|QFile::WriteUser|QFile::WriteOther); QFile::setPermissions(elem.getPath(), permissions); } } } else { notifyUser(Ui::Notification::eCRITICAL , tr("Error") , tr("File upload failed (") + elem.getName() + QString(")")); } WebMounter::getProxy()->fileUploaded(fInfo.absoluteFilePath(), err); return err; }
bool Transition::operator==(const Transition& b) const { return valid==b.valid && program()==b.program() && transitFrom()==b.transitFrom() && transitTo()==b.transitTo() && promptUser()==b.promptUser() && notifyUser()==b.notifyUser(); }