static PyObject *meth_QSystemSemaphore_setKey(PyObject *sipSelf, PyObject *sipArgs, PyObject *sipKwds) { PyObject *sipParseErr = NULL; { const QString* a0; int a0State = 0; int a1 = 0; QSystemSemaphore::AccessMode a2 = QSystemSemaphore::Open; QSystemSemaphore *sipCpp; static const char *sipKwdList[] = { NULL, sipName_initialValue, sipName_mode, }; if (sipParseKwdArgs(&sipParseErr, sipArgs, sipKwds, sipKwdList, NULL, "BJ1|iE", &sipSelf, sipType_QSystemSemaphore, &sipCpp, sipType_QString,&a0, &a0State, &a1, sipType_QSystemSemaphore_AccessMode, &a2)) { Py_BEGIN_ALLOW_THREADS sipCpp->setKey(*a0,a1,a2); Py_END_ALLOW_THREADS sipReleaseType(const_cast<QString *>(a0),sipType_QString,a0State); Py_INCREF(Py_None); return Py_None; } } /* Raise an exception if the arguments couldn't be parsed. */ sipNoMethod(sipParseErr, sipName_QSystemSemaphore, sipName_setKey, doc_QSystemSemaphore_setKey); return NULL; }
static void tSystemMessage(int priority, const char *msg, va_list ap) { static QSystemSemaphore semaphore("TreeFrogSystemLog", 1, QSystemSemaphore::Open); TLog log(priority, QString().vsprintf(msg, ap).toLocal8Bit()); QByteArray buf = TLogger::logToByteArray(log, syslogLayout, syslogDateTimeFormat); semaphore.acquire(); // Acquires the semaphore for system log if (!systemLog.fileName().isEmpty() && systemLog.open(QIODevice::WriteOnly | QIODevice::Append | QIODevice::Text)) { systemLog.write(buf.data()); systemLog.flush(); systemLog.close(); } semaphore.release(); // Releases the semaphore }
HbCacheLocker(QSystemSemaphore &semaphore) : semaphore(semaphore) { semaphore.acquire(); }
int main(int argc, char *argv[]) { QGuiApplication::setAttribute(Qt::AA_EnableHighDpiScaling); QApplication a(argc, argv); auto startMinimized = false; QString uri = ""; for (auto string : QCoreApplication::arguments()) { if (string == "-m" || string == "--minimized") startMinimized = true; if (string == "-d" || string == "--debug") Console(); if (string.startsWith("ring:")) { uri = string; } } #ifdef URI_PROTOCOL QSharedMemory* shm = new QSharedMemory("RingShm"); QSystemSemaphore* sem = new QSystemSemaphore("RingSem", 0); if (not shm->create(1024)) { if (not uri.isEmpty()) { shm->attach(); shm->lock(); char *to = (char*) shm->data(); QChar *data = uri.data(); while (!data->isNull()) { memset(to, data->toLatin1(), 1); ++data; ++to; } memset(to, 0, 1); //null terminator shm->unlock(); } sem->release(); delete shm; exit(EXIT_SUCCESS); } //Client listening to shm event memset((char*)shm->data(), 0, shm->size()); ShmClient* shmClient = new ShmClient(shm, sem); #endif QTranslator qtTranslator; qtTranslator.load("qt_" + QLocale::system().name(), QLibraryInfo::location(QLibraryInfo::TranslationsPath)); a.installTranslator(&qtTranslator); QTranslator lrcTranslator; lrcTranslator.load("share/libringclient/translations/lrc_" + QLocale::system().name()); a.installTranslator(&lrcTranslator); QTranslator mainTranslator; mainTranslator.load("share/ring/translations/ring_client_windows_" + QLocale::system().name()); a.installTranslator(&mainTranslator); QFont font; font.setFamily("Segoe UI"); a.setFont(font); QFile file(":/stylesheet.css"); if(file.open(QIODevice::ReadOnly | QIODevice::Text)) { a.setStyleSheet(file.readAll()); file.close(); } QCoreApplication::setOrganizationName("Savoir-faire Linux"); QCoreApplication::setOrganizationDomain("ring.cx"); QCoreApplication::setApplicationName("Ring"); if (not uri.isEmpty()) { startMinimized = false; MainWindow::instance().onRingEvent(uri); } if (not startMinimized) MainWindow::instance().show(); else { MainWindow::instance().showMinimized(); MainWindow::instance().hide(); } MainWindow::instance().createThumbBar(); #ifdef URI_PROTOCOL QObject::connect(shmClient, SIGNAL(RingEvent(QString)), &MainWindow::instance(), SLOT(onRingEvent(QString))); QObject::connect(&a, &QApplication::aboutToQuit, [&a, &shmClient, &shm, &sem]() { shmClient->terminate(); delete shmClient; delete shm; delete sem; }); #endif return a.exec(); }
bool release_jt9_() {return sem_jt9.release();}
bool acquire_jt9_() {return sem_jt9.acquire();}