void QVFbView::initLock() { QString username = "******"; const char *logname = getenv("LOGNAME"); if ( logname ) username = logname; qwslock = new QLock(qws_dataDir() + QString( QTE_PIPE ).arg( displayid ), 'd', TRUE); }
QString qws_fontCacheDir() { QString dir; #if defined(Q_WS_QWS) extern QString qws_dataDir(); dir = qws_dataDir(); #else dir = QDir::tempPath(); #endif dir.append(QLatin1String("/fonts/")); QDir qd(dir); if (!qd.exists() && !qd.mkpath(dir)) dir = QDir::tempPath(); return dir; }
QShMemViewProtocol::QShMemViewProtocol(int displayid, const QSize &s, int d, QObject *parent) : QVFbViewProtocol(displayid, parent), hdr(0), dataCache(0), lockId(-1), windowId(0) { int w = s.width(); int h = s.height(); QString username = "******"; const char *logname = getenv("LOGNAME"); if ( logname ) username = logname; qws_dataDir(displayid); { QString oldPipe = "/tmp/qtembedded-" + username + "/" + QString("QtEmbedded-%1").arg(displayid); QLock oldPipeLock(oldPipe, 'd', false); if (oldPipeLock.isValid()) { perror("QShMemViewProtocol::QShMemViewProtocol"); qFatal("Cannot create lock file as an old version of QVFb has " "opened %s. Close other QVFb and try again", oldPipe.toLatin1().constData()); } } displayPipe = QTE_PIPE_QVFB(displayid); kh = new QVFbKeyPipeProtocol(displayid); /* should really depend on receiving qt version, but how can one tell? */ mh = new QVFbMousePipe(displayid); QString mousePipe = mh->pipeName(); key_t key = ftok(mousePipe.toLatin1().constData(), 'b'); int bpl; if (d < 8) bpl = (w * d + 7) / 8; else bpl = w * ((d + 7) / 8); displaySize = bpl * h; unsigned char *data; uint data_offset_value = sizeof(QVFbHeader); int dataSize = bpl * h + data_offset_value; shmId = shmget(key, dataSize, IPC_CREAT | 0600); if (shmId != -1) data = (unsigned char *)shmat(shmId, 0, 0); else { struct shmid_ds shm; shmctl(shmId, IPC_RMID, &shm); shmId = shmget(key, dataSize, IPC_CREAT | 0600); if (shmId == -1) { perror("QShMemViewProtocol::QShMemViewProtocol"); qFatal("Cannot get shared memory 0x%08x", key); } data = (unsigned char *)shmat(shmId, 0, 0); } if ((long)data == -1) { delete kh; delete mh; perror("QShMemViewProtocol::QShMemViewProtocol"); qFatal("Cannot attach to shared memory %d",shmId); } dataCache = (unsigned char *)malloc(displaySize); memset(dataCache, 0, displaySize); memset(data+sizeof(QVFbHeader), 0, displaySize); hdr = (QVFbHeader *)data; hdr->width = w; hdr->height = h; hdr->depth = d; hdr->linestep = bpl; hdr->dataoffset = data_offset_value; hdr->update = QRect(); hdr->dirty = 0; hdr->numcols = 0; hdr->viewerVersion = QT_VERSION; hdr->brightness = 255; hdr->windowId = 0; displayPiped = displayPipe + 'd'; mRefreshTimer = new QTimer(this); connect(mRefreshTimer, SIGNAL(timeout()), this, SLOT(flushChanges())); }