void DBusOperationQueueHandler::Operation::copy(const char *name,
        const QList<QGenericArgument *> &args)
{
    Q_ASSERT(name != NULL);

    m_name = new char[qstrlen(name) + 1];
    qstrcpy(m_name, name);

    QListIterator<QGenericArgument *> it(args);
    while (it.hasNext()) {
        QGenericArgument *arg = it.next();
        int type = QMetaType::type(arg->name());
        if (!QMetaType::isRegistered(type)) {
            qCritical()
                    << Q_FUNC_INFO
                    << QString(QLatin1String("Type %1 not registered."))
                    .arg(QLatin1String(arg->name()));
        } else {
            Q_ASSERT(arg->name() != NULL);

            char *localName = new char[qstrlen(arg->name()) + 1];
            qstrcpy(localName, arg->name());
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
            void *localData = QMetaType::construct(type, arg->data());
#else
            void *localData = QMetaType::create(type, arg->data());
#endif

            m_args << (new QGenericArgument(localName, localData));
        }
    }
}
示例#2
0
void QWhatsThis::add( QWidget * widget, const QPixmap & icon,
		      const char * title, const char * text,
		      bool deepCopy )
{
    QWhatsThisPrivate::setUpWhatsThis();
    QWhatsThisPrivate::Item * i = wt->dict->find( (void *)widget );
    if ( i )
	remove( widget );

    i = new QWhatsThisPrivate::Item;
    i->dc = deepCopy;
    if ( deepCopy ) {
	i->s = new char[ qstrlen(text) + 1 ];
	qstrcpy( i->s, text );
	if ( title ) {
	    i->t = new char[ qstrlen(text) + 1 ];
	    qstrcpy( i->t, text );
	}
    } else {
	i->s = (char*)text;
	i->t = (char*)title;
    }
    i->pm = icon;
    wt->dict->insert( (void *)widget, i );
    QWidget * tlw = widget->topLevelWidget();
    if ( !wt->tlw->find( (void *)tlw ) ) {
	wt->tlw->insert( (void *)tlw, tlw );
	tlw->installEventFilter( wt );
    }
}
示例#3
0
int ownCloudFolder::getauth(const char *prompt,
                         char *buf,
                         size_t len,
                         int echo,
                         int verify,
                         void *userdata
                         )
{
    int re = 0;
    QMutex mutex;

    QString qPrompt = QString::fromLatin1( prompt ).trimmed();
    QString user = CredentialStore::instance()->user();
    QString pwd  = CredentialStore::instance()->password();

    if( qPrompt == QLatin1String("Enter your username:"******"OOO Username requested!";
        QMutexLocker locker( &mutex );
        qstrncpy( buf, user.toUtf8().constData(), len );
    } else if( qPrompt == QLatin1String("Enter your password:"******"OOO Password requested!";
        qstrncpy( buf, pwd.toUtf8().constData(), len );
    } else {
        if( qPrompt.startsWith( QLatin1String("There are problems with the SSL certificate:"))) {
            // SSL is requested. If the program came here, the SSL check was done by mirall
            // It needs to be checked if the  chain is still equal to the one which
            // was verified by the user.
            QRegExp regexp("fingerprint: ([\\w\\d:]+)");
            bool certOk = false;

            int pos = 0;

            // This is the set of certificates which QNAM accepted, so we should accept
            // them as well
            QList<QSslCertificate> certs = ownCloudInfo::instance()->certificateChain();

            while (!certOk && (pos = regexp.indexIn(qPrompt, 1+pos)) != -1) {
                QString neon_fingerprint = regexp.cap(1);

                foreach( const QSslCertificate& c, certs ) {
                    QString verified_shasum = Utility::formatFingerprint(c.digest(QCryptographicHash::Sha1).toHex());
                    qDebug() << "SSL Fingerprint from neon: " << neon_fingerprint << " compared to verified: " << verified_shasum;
                    if( verified_shasum == neon_fingerprint ) {
                        certOk = true;
                        break;
                    }
                }
            }
            // certOk = false;     DEBUG setting, keep disabled!
            if( !certOk ) { // Problem!
                qstrcpy( buf, "no" );
                re = -1;
            } else {
                qstrcpy( buf, "yes" ); // Certificate is fine!
            }
        } else {
void RInterface::processRCallbackRequest (RCallbackArgs *args) {
	RK_TRACE (RBACKEND);

	// first, copy out the type. Allows for easier typing below
	RCallbackArgs::RCallbackType type = args->type;

	if (type == RCallbackArgs::RShowMessage) {
		KMessageBox::information (0, QString (*(args->chars_a)), i18n ("Message from the R backend"));
	} else if (type == RCallbackArgs::RReadConsole) {
		QString result;

		bool ok = RKReadLineDialog::readLine (0, i18n ("R backend requests information"), *(args->chars_a), runningCommand (), &result);

		result = result.left (args->int_a - 2) + "\n";
		qstrcpy (*(args->chars_b), result.latin1 ());

		if (!ok) {
			args->done = true;		// need to do this at once. Else we risk getting stuck in the standard callback event loop
			cancelCommand (runningCommand ());
			return;
		}
	} else if ((type == RCallbackArgs::RShowFiles) || (type == RCallbackArgs::REditFiles)) {
		if ((type == RCallbackArgs::RShowFiles) && (QString (*(args->chars_d)) == "rkwardhtml")) {
			// not to worry, just some help file to display
			// TODO: maybe move this to ShowEditTextFileAgent instead
			for (int n=0; n < args->int_a; ++n) {
				RKwardApp::getApp ()->openHTML (args->chars_a[n]);
			}
		} else {
			ShowEditTextFileAgent::showEditFiles (args);
			return;
		}
	} else if (type ==RCallbackArgs::RChooseFile) {
		QString filename;
		if (args->int_a) {
			filename = KFileDialog::getSaveFileName ();
		} else {
			filename = KFileDialog::getOpenFileName ();
		}
		filename = filename.left (args->int_b - 2);
		args->int_c = filename.length ();
		qstrcpy (*(args->chars_a), filename.latin1 ());
	} else if (type ==RCallbackArgs::RSuicide) {
		QString message = i18n ("The R engine has encountered a fatal error:\n") + QString (*(args->chars_a));
		message += i18n ("It will be shut down immediately. This means, you can not use any more functions that rely on the R backend. I.e. you can do hardly anything at all, not even save the workspace. What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that. Sorry!");
		KMessageBox::error (0, message, i18n ("R engine has died"));
		r_thread->terminate ();
	} else if (type ==RCallbackArgs::RCleanUp) {
		QString message = i18n ("The R engine has shut down with status: ") + QString::number (args->int_a);
		message += i18n ("\nIt will be shut down immediately. This means, you can not use any more functions that rely on the R backend. I.e. you can do hardly anything at all, not even save the workspace. Hopefully, however, R has already saved the workspace. What you can do, however, is save any open command-files, the output, or copy data out of open data editors. Quit RKWard after that.\nSince this should never happen, please write a mail to [email protected], and tell us, what you were trying to do, when this happened. Sorry!");
		KMessageBox::error (0, message, i18n ("R engine has died"));
		r_thread->terminate ();
	}

	args->done = true;
}
示例#5
0
QBuffer* CRecordData::Raw2Wav(QBuffer *bufRawRecord)
{
    HEADER pcmHEADER;
    FMT pcmFMT;
    DATA pcmDATA;

    QFile *fp, *fpCopy;
    fp = new QFile();
    fpCopy = new QFile();
    fp->setFileName("record.raw");
    fp->open( QIODevice::ReadOnly );
    fpCopy->setFileName("record.wav");
    fpCopy->open( QIODevice::ReadWrite | QIODevice::Append );



    qstrcpy(pcmHEADER.fccID, "RIFF");
    qstrcpy(pcmHEADER.fccType, "WAVE");
    pcmFMT.dwSamplesPerSec = 44100;
    pcmFMT.dwAvgBytesPerSec = pcmFMT.dwSamplesPerSec*2*2;
    pcmFMT.uiBitsPerSample = 16;

    qstrcpy(pcmFMT.fccID, "fmt ");
    pcmFMT.dwSize = 16;
    pcmFMT.wBlockAlign = 4;
    pcmFMT.wChannels = 2;
    pcmFMT.wFormatTag = 1;


    QByteArray fpDate = fp->readAll();

    qstrcpy(pcmDATA.fccID, "data");
    pcmDATA.dwSize = fpDate.length();
    pcmHEADER.dwSize = 44+fpDate.length()-8; //根据pcmDATA.dwsize得出pcmHEADER.dwsize的值

    QByteArray se;
    se.resize(44);
    memcpy(se.data(),&pcmHEADER,sizeof(pcmHEADER));
    memcpy(se.data()+sizeof(pcmHEADER),&pcmFMT,sizeof(pcmFMT));
    memcpy(se.data()+sizeof(pcmHEADER)+sizeof(pcmFMT),&pcmDATA,sizeof(pcmDATA));

    fpCopy->write(se);

    fpCopy->seek(44);

    fpCopy->write(fpDate);


    fpCopy->close();
    fp->close();
}
示例#6
0
文件: qlog.c 项目: Zengwn/qlibc
static bool _real_open(qlog_t *log) {
    const time_t nowtime = time(NULL);

    /* generate filename */
    char newfilepath[PATH_MAX];
    strftime(newfilepath, sizeof(newfilepath), log->filepathfmt,
             localtime(&nowtime));

    /* open or re-open log file */
    if (log->fp == NULL) {
        log->fp = fopen(newfilepath, "a");
        if (log->fp == NULL) {
            DEBUG("_real_open: Can't open log file '%s'.", newfilepath);
            return false;
        }

        if (log->mode != 0)
            fchmod(fileno(log->fp), log->mode);
        qstrcpy(log->filepath, sizeof(log->filepath), newfilepath);
    } else if (strcmp(log->filepath, newfilepath)) {
        /* have opened stream, only reopen if new filename is different with
         existing one */
        FILE *newfp = fopen(newfilepath, "a");
        if (newfp != NULL) {
            if (log->mode != 0)
                fchmod(fileno(newfp), log->mode);
            fclose(log->fp);
            log->fp = newfp;
            qstrcpy(log->filepath, sizeof(log->filepath), newfilepath);
        } else {
            DEBUG("_real_open: Can't open log file '%s' for rotating.",
                    newfilepath);
        }
    } else {
        DEBUG("_real_open: skip re-opening log file.");
    }

    /* set next rotate time */
    if (log->rotateinterval > 0) {
        time_t ct = time(NULL);
        time_t dt = ct - mktime(gmtime(&ct));
        log->nextrotate = (((ct + dt) / log->rotateinterval) + 1)
                * log->rotateinterval - dt;
    } else {
        log->nextrotate = 0;
    }

    return true;
}
void cConsole::notifyServerState( enServerState newstate )
{
	// Required ugly stuff
#if !defined (NIF_INFO)
# define NIF_INFO   	 0x00000010
#endif
#if !defined(NIIF_INFO)
# define NIIF_INFO  	 0x00000001
#endif

	icondata.uFlags = NIF_ICON;

	if ( newstate == RUNNING )
	{
		icondata.hIcon = iconGreen;
	}
	else
	{
		icondata.hIcon = iconRed;
	}

#if (_WIN32_IE >= 0x0500)
	qstrcpy( icondata.szInfoTitle, "Wolfpack Server Status" );
	// Startup has finished
	if ( Server::instance()->getState() == STARTUP && newstate == RUNNING )
	{
		icondata.uFlags |= NIF_INFO;
		icondata.uTimeout = 2500;
		icondata.dwInfoFlags = NIIF_INFO;
		qstrcpy( icondata.szInfo, "Wolfpack has started up and is now ready to use." );
	}
	else if ( Server::instance()->getState() == SCRIPTRELOAD && newstate == RUNNING )
	{
		icondata.uFlags |= NIF_INFO;
		icondata.uTimeout = 2500;
		icondata.dwInfoFlags = NIIF_INFO;
		qstrcpy( icondata.szInfo, "Wolfpack has finished reloading the scripts." );
	}
	else if ( newstate == SHUTDOWN )
	{
		icondata.uFlags |= NIF_INFO;
		icondata.uTimeout = 2500;
		icondata.dwInfoFlags = NIIF_INFO;
		qstrcpy( icondata.szInfo, "Wolfpack is now shutting down." );
	}
#endif

	Shell_NotifyIconA( NIM_MODIFY, ( PNOTIFYICONDATAA ) & icondata );
}
示例#8
0
void UIDropMsg::on_okButton_clicked()
{
	djDebug()<<"UIDropMsg::on_okButton_clicked";
	
	QString broadcastMsg	= lineEdit->text();
    QByteArray	utf8	= broadcastMsg.toUtf8();
    	
	QByteArray	buf(sizeof(DJGameProtocol)+sizeof(ChatContent) + utf8.size() + 1,0);
    DJGameProtocol *protocol	= reinterpret_cast<DJGameProtocol *>(buf.data());
    protocol->chTotalLen	= buf.size();
    protocol->chType = DJGAME_PROTOCOL_TYPE_CHAT;
    protocol->chLanguage = m_gameController->language();     
        
    ChatContent	*chat	= reinterpret_cast<ChatContent *>(protocol->chBuf);
    setle4( &chat->userid_speaker, m_gameController->selfUserId() );
    setle4( &chat->userid_listener, DJGAME_PLAYER_BROADCAST );
    chat->chGameClass = hibyte(m_gameController->gameId());
    chat->chGame = lobyte(m_gameController->gameId());
    
    qstrcpy( chat->szSentence, utf8.data() );
    
	DJClientRequest request( buf );
	m_gameController->sendRequest( request );
	
	close();
}
示例#9
0
QGLAbstractScene *QGL3dsSceneHandler::read()
{
    Lib3dsFile *file = qgl3ds_lib3ds_file_load(device());
    Q_CHECK_PTR(file);  // wtf?

    if (!file->nodes)
    {
        Lib3dsMesh *mesh;
        Lib3dsNode *node;
        for (mesh = file->meshes; mesh; mesh = mesh->next)
        {
            if (mesh->faces && mesh->points)
            {
                node = lib3ds_node_new_object();
                qstrcpy(node->name, mesh->name);
                node->parent_id = LIB3DS_NO_PARENT;
                lib3ds_file_insert_node(file, node);
            }
        }
    }

    lib3ds_file_eval(file, 0.0f);

    QGL3dsScene *scene = new QGL3dsScene(file, this);
    return scene;
}
示例#10
0
文件: config.c 项目: Zengwn/qhttpd
bool checkConfig(struct ServerConfig *pConf)
{
    // allowed methods parsing
    qstrupper(pConf->szAllowedMethods);
    if (!strcmp(pConf->szAllowedMethods, "ALL")) {
        qstrcpy(pConf->szAllowedMethods, sizeof(pConf->szAllowedMethods),
                "OPTIONS,HEAD,GET,PUT"
                ","
                "PROPFIND,PROPPATCH,MKCOL,MOVE,DELETE,LOCK,UNLOCK");
    }

    if (strstr(pConf->szAllowedMethods, "OPTIONS") != NULL) pConf->methods.bOptions = true;
    if (strstr(pConf->szAllowedMethods, "HEAD") != NULL) pConf->methods.bHead = true;
    if (strstr(pConf->szAllowedMethods, "GET") != NULL) pConf->methods.bGet = true;
    if (strstr(pConf->szAllowedMethods, "PUT") != NULL) pConf->methods.bPut = true;

    if (strstr(pConf->szAllowedMethods, "PROPFIND") != NULL) pConf->methods.bPropfind = true;
    if (strstr(pConf->szAllowedMethods, "PROPPATCH") != NULL) pConf->methods.bProppatch = true;
    if (strstr(pConf->szAllowedMethods, "MKCOL") != NULL) pConf->methods.bMkcol = true;
    if (strstr(pConf->szAllowedMethods, "MOVE") != NULL) pConf->methods.bMove = true;
    if (strstr(pConf->szAllowedMethods, "DELETE") != NULL) pConf->methods.bDelete = true;
    if (strstr(pConf->szAllowedMethods, "LOCK") != NULL) pConf->methods.bLock = true;
    if (strstr(pConf->szAllowedMethods, "UNLOCK") != NULL) pConf->methods.bUnlock = true;

    return true;
}
示例#11
0
void editor::actNew()
{
    if (levelLoaded)
        level.clear();
    int wNew = QInputDialog::getInt(this, QString("Creating the map"), QString("Width:"), 0, 0, 1024);
    int hNew = QInputDialog::getInt(this, QString("Creating the map"), QString("Height:"), 0, 0, 1024);
    QString nameNew = QInputDialog::getText(this, QString("Creating the map"), QString("Name:"));

    QFile f("maps/"+nameNew+".snsmap");
    f.open(QIODevice::WriteOnly);
    QDataStream out(&f);
    _map tmp;
    tmp.w=wNew;
    tmp.h=hNew;
    tmp.allocate();
    for (int i=0; i<tmp.w; i++)
        for (int j=0; j<tmp.h; j++)
        {
            tmp[i][j].type = 0;
            qstrcpy(tmp[i][j].color, "#ffffff");
            tmp[i][j].durability = 0;
        }
    out << tmp;

    readLevel("maps/"+nameNew+".snsmap");
}
示例#12
0
void editor::setTile(int x, int y, int type, char color[], double durability)
{
    if (x<0||x>=level.w||y<0||y>=level.h)throw (char *)"Exception: tile is not in range.";
    level[x][y].type = type;
    qstrcpy(level[x][y].color, color);
    level[x][y].durability = durability;
}
示例#13
0
int CSyncThread::getauth(const char *prompt,
                         char *buf,
                         size_t len,
                         int echo,
                         int verify,
                         void *userdata
                         )
{
    int re = 0;

    QString qPrompt = QString::fromLocal8Bit( prompt ).trimmed();
    _mutex.lock();

    if( qPrompt == QLatin1String("Enter your username:"******"OOO Username requested!";
        qstrncpy( buf, _user.toUtf8().constData(), len );
    } else if( qPrompt == QLatin1String("Enter your password:"******"OOO Password requested!";
        qstrncpy( buf, _passwd.toUtf8().constData(), len );
    } else {
        if( qPrompt.startsWith( QLatin1String("There are problems with the SSL certificate:"))) {
            // SSL is requested. If the program came here, the SSL check was done by mirall
            // the answer is simply yes here.
            qstrcpy( buf, "yes" );
        } else {
            qDebug() << "Unknown prompt: <" << prompt << ">";
            re = -1;
        }
    }
    _mutex.unlock();
    return re;
}
示例#14
0
void editor::listenToMouse()
{
    if (levelLoaded)
    {
        if (pressedL)
        {
            int x = floor((xMouseReal-xCorner)/double(tilesize));
            int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1;
            switch (mode)
            {
            case 0:
            case 1:
            case 2:
                try {
                    setTile(x, y, mode,
                            mode?selectedColor:(char *)"#ffffff",
                            selectedDurability);
                } catch (...) {}
                updateTile(x, y);
                break;
            case 3:
                if (x>=0 && y>=0 && x<level.w && y<level.h && tileType(x, y))
                {
                    int h=0, s=0, v=0;
                    int c = 0;
                    for (int i=-1; i<2; i++)
                        for (int j=-1; j<2; j++, c++)
                        {
                            try {
                                QColor tmp(tileColor(x+i, y+j));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            } catch (...) {
                                QColor tmp(tileColor(x+(-1*i), y+(-1*j)));
                                h += tmp.hue();
                                s += tmp.saturation();
                                v += tmp.value();
                            }
                        }
                    h /= c;
                    s /= c;
                    v /= c;
                    QColor q;
                    q.setHsv(h, s, v);
                    char m[8];
                    for (int i=0; i<8; i++)
                        m[i] = (q.name().constData()+i)->toAscii();
                    qstrcpy(tileColor(x, y), m);
                    updateTile(x, y);
                    break;
                }
            }
        }
    }
}
示例#15
0
void TopScores::on_Azzera_clicked()
{
    for (int i=0; i<10; i++)
    {
        qstrcpy(Topscores[i].Nome, "nDisp");
        Topscores[i].POINTS = 0;
    }
    update_table();
    save_load_t.save(Topscores);
}
SearchQuery::SearchQuery(const DNASequence *shortRead, SearchQuery *revCompl) {
    dna = true;
    wroteResult = false;
    this->revCompl = revCompl;
    seqLength = shortRead->length();
    nameLength = shortRead->getName().length();
    seq = new char[seqLength+1];
    name = new char[nameLength+1];
    qstrcpy(seq, shortRead->constData());
    qstrcpy(name, shortRead->getName().toLatin1().constData());
    if (shortRead->hasQualityScores()) {
        quality = new DNAQuality(shortRead->quality);
    } else {
        quality = NULL;
    }

    results.reserve(2);
    mismatchCounts.reserve(2);
    overlapResults.reserve(2);
}
unsigned int GraphicsVlcItem::formatCallback(char *chroma,
                                                 unsigned *width, unsigned *height,
                                                 unsigned *pitches, unsigned *lines)
{
#if Q_BYTE_ORDER == Q_LITTLE_ENDIAN
    qstrcpy(chroma, "BGRA");
#else
    qstrcpy(chroma, "ARGB");
#endif

    _frame.width = *width;
    _frame.height = *height;
    _frame.planeCount = 1;

    setVideoRect();

    _frame.visiblePitch[0] = _frame.pitch[0] = pitches[0] = *width * 4;
    _frame.visibleLines[0] = _frame.lines[0] = lines[0] = *height;
    _frame.plane[0].resize(pitches[0] * lines[0]);

    return pitches[0] * lines[0];
}
示例#18
0
void Scenario::getRoles(char *roles) const {
    qstrcpy(roles, "Z");

    int i;
    for(i=0; i<loyalists.length(); i++)
        strcat(roles, "C");

    for(i=0; i<rebels.length(); i++)
        strcat(roles, "N");

    for(i=0; i<rebels.length(); i++)
        strcat(roles, "F");
}
示例#19
0
文件: qsocket.c 项目: Cybsloth/qlibc
/**
 * Return local IP address.
 *
 * @return malloced string pointer which contains IP address string if
 *         successful, otherwise returns NULL
 */
char *qsocket_get_localaddr(char *buf, size_t bufsize) {
    char hostname[63 + 1];
    if (gethostname(hostname, sizeof(hostname)) != 0)
        return NULL;

    struct hostent *hostentry = gethostbyname(hostname);
    if (hostentry == NULL)
        return NULL;

    char *localip = inet_ntoa(*(struct in_addr *) *hostentry->h_addr_list);
    if (localip == NULL)
        return NULL;

    qstrcpy(buf, bufsize, localip);
    return buf;
}
示例#20
0
文件: qlog.c 项目: Zengwn/qlibc
/**
 * Open ratating-log file
 *
 * @param filepathfmt     filename format. formatting argument is same as
 *                        strftime()
 * @param mode            new file mode. 0 for system default
 * @param rotateinterval  rotating interval seconds, set 0 to disable rotation
 * @param options         combination of options.
 *
 * @return a pointer of qlog_t structure
 *
 * @note
 *  rotateinterval is not relative time. If you set it to 3600, log file will be
 *  rotated at every hour. And filenameformat is same as strftime(). So If you
 *  want to log with hourly rotating, filenameformat must be defined including
 *  hour format like "/somepath/xxx-%Y%m%d%H.log". You can set it to
 *  "/somepath/xxx-%H.log" for daily overrided log file.
 *
 * @note
 *   Available options:
 *   - QLOG_OPT_THREADSAFE - make it thread-safe.
 *   - QLOG_OPT_FLUSH -  flush out buffer everytime.
 *
 * @code
 *   qlog_t *log = qlog("/tmp/qdecoder-%Y%m%d.err", 0644, 86400, QLOG_OPT_THREADSAFE);
 *   log->free(log);
 * @endcode
 */
qlog_t *qlog(const char *filepathfmt, mode_t mode, int rotateinterval,
             int options) {
    qlog_t *log;

    // malloc qlog_t structure
    log = (qlog_t *) calloc(1, sizeof(qlog_t));
    if (log == NULL) {
        errno = ENOMEM;
        return NULL;
    }

    // set up the structure.
    qstrcpy(log->filepathfmt, sizeof(log->filepathfmt), filepathfmt);
    log->mode = mode;
    if (rotateinterval > 0)
        log->rotateinterval = rotateinterval;

    // handle options
    if (options & QLOG_OPT_THREADSAFE) {
        Q_MUTEX_NEW(log->qmutex, true);
        if (log->qmutex == NULL) {
            errno = ENOMEM;
            free(log);
            return NULL;
        }
    }
    if (options & QLOG_OPT_FLUSH) {
        log->logflush = true;
    }

    // try to open the log file.
    if (_real_open(log) == false) {
        free(log);
        Q_MUTEX_DESTROY(log->qmutex);
        return NULL;
    }

    // member methods
    log->write = write_;
    log->writef = writef;
    log->duplicate = duplicate;
    log->flush = flush_;
    log->free = free_;

    return log;
}
示例#21
0
QGString::QGString( const QGString &s ) 
{ 
  if (s.m_memSize==0)
  {
    m_data    = 0;
    m_len     = 0;
    m_memSize = 0;
  }
  else
  {
    m_data    = (char *)malloc(s.m_memSize); 
    m_len     = s.m_len;
    m_memSize = s.m_memSize;
    qstrcpy(m_data,s.m_data);
  }
  DBG_STR(("%p: QGString::QGString(const QGString &) %d:%s\n",this,m_len,m_data?m_data:"<none>"));
} 
// --------------------------------------------------------------------------
void ctkChar2DArray::setValues(const QStringList& list)
{
  Q_D(ctkChar2DArray);
  this->clear();
  if (list.isEmpty())
    {
    return;
    }
  d->List = list;
  d->Count = list.count();
  d->Values = new char*[list.count()];
  for(int index = 0; index < d->List.count(); ++index)
    {
    QString item = d->List.at(index);
    d->Values[index] = new char[item.size()];
    qstrcpy(d->Values[index], item.toLatin1().data());
    }
}
示例#23
0
QGString::QGString( const char *str )
{
  if (str==0)
  {
    m_data=0;
    m_len=0;
    m_memSize=0;
  }
  else
  {
    m_len = qstrlen(str);
    m_memSize = ROUND_SIZE(m_len+1);
    assert(m_memSize>=m_len+1);
    m_data = (char *)malloc(m_memSize);
    qstrcpy(m_data,str);
  }
  DBG_STR(("%p: QGString::QGString(const char *) %d:%s\n",this,m_len,m_data?m_data:"<none>"));
}
示例#24
0
const char *SettingsWidget::lookForWidgetState(QWidget *widget, const char *property, const char *signal)
{
	const QMetaObject *meta = widget->metaObject();
	WidgetInfo info = { widget, NULL, QVariant(), false };
	bool free_signal = false;
	// Firstly try to search this widget in predefined classes
	if (!signal && !property) {
		for (int i = 0, size = sizeof(widget_infos) / sizeof(AbstractWidgetInfo*); i < size; i++) {
			if (widget_infos[i]->handle(widget)) {
				info.property = widget_infos[i]->property;
				signal = widget_infos[i]->signal;
				break;
			}
		}
	}
	// Then try to find "User" property with signal or signal by property
	if (!signal) {
		for (int i = 0, size = meta->propertyCount(); i < size; i++) {
			QMetaProperty prop = meta->property(i);
			if (prop.hasNotifySignal()
				&& ((property && !qstrcmp(prop.name(), property))
					|| (!property && prop.isUser()))) {
				info.property = prop.name();
				const char *sig = prop.notifySignal().signature();
				int len = strlen(sig);
				char *str = (char *)qMalloc(sizeof(char) * (len + 2));
				str[0] = QSIGNAL_CODE;
				qstrcpy(str + 1, sig);
				signal = str;
				free_signal = true;
				break;
			}
		}
	}
	bool result(signal);
	if (result) {
		p->mapper->setMapping(widget, p->infos.size());
		connect(widget, signal, p->mapper, SLOT(map()));
		p->infos << info;
	}
	if (free_signal)
		qFree((void *)signal);
	return result ? info.property : 0;
}
示例#25
0
QByteArray BasketUtils::hashPassword( QString password )
{
#if QT_VERSION >= 0x040300
    QByteArray hash = QCryptographicHash::hash( password.toUtf8(), QCryptographicHash::Md5 );
    return hash;
#else
    char *hash_ptr = new char[16];
    char *pwd = new char[password.size()];
    qstrcpy(pwd, password.toUtf8().data());
    hash_ptr = (char*)MD5((unsigned char *)pwd, password.size(), NULL);
    if ( hash_ptr ) {
        QByteArray hash = QByteArray( hash_ptr, 16 );
        delete [] pwd;
        return hash;
    }
    delete [] pwd;

    return QByteArray();
#endif
}
示例#26
0
QGString &QGString::operator=( const char *str ) 
{ 
  if (m_data) free(m_data);
  if (str==0) // null string
  {
    m_data    = 0;
    m_len     = 0;
    m_memSize = 0;
  }
  else
  {
    m_len     = qstrlen(str);
    m_memSize = ROUND_SIZE(m_len+1);
    assert(m_memSize>=m_len+1);
    m_data    = (char*)malloc(m_memSize);
    qstrcpy(m_data,str);
  }
  DBG_STR(("%p: QGString::operator=(const char *) %d:%s\n",this,m_len,m_data?m_data:"<none>"));
  return *this;
}
示例#27
0
QGString &QGString::operator=( const QGString &s ) 
{
  if (m_data) free(m_data);
  if (s.m_memSize==0) // null string
  {
    m_data    = 0;
    m_len     = 0;
    m_memSize = 0;
  }
  else
  {
    m_len     = s.m_len;
    m_memSize = s.m_memSize;
    m_data    = (char*)malloc(m_memSize);
    qstrcpy(m_data,s.m_data);
  }
  DBG_STR(("%p: QGString::operator=(const QGString &%p) %d:%s\n",
      this,&s,m_len,m_data?m_data:"<none>"));
  return *this;
}
示例#28
0
void editor::mousePressEvent(QMouseEvent *event)
{
    xMouseReal = event->x();
    yMouseReal = event->y();
    switch (event->button()) {
    case LeftButton:
        pressedL = true;
        break;
    case RightButton:
        pressedR = true;
        break;
    case MiddleButton:
    {
        int x = floor((xMouseReal-xCorner)/double(tilesize));
        int y = level.h - floor((yMouseReal-yCorner)/double(tilesize)) - 1;
        qstrcpy(selectedColor, tileColor(x, y));
        break;
    }
    default:    // fixing warnings...
        break;
    }
    listenToMouse();
}
示例#29
0
unsigned int VlcQmlVideoObject::formatCallback(char *chroma,
                                                 unsigned *width, unsigned *height,
                                                 unsigned *pitches, unsigned *lines)
{
    qDebug() << "Format:"
             << "chroma:" << chroma
             << "width:" << *width
             << "height:" << *height
             << "pitches:" << *pitches
             << "lines:" << *lines;

    if (!_graphicsPainter)
        _graphicsPainter = new GlslPainter;

    qstrcpy(chroma, "YV12");
    const vlc_chroma_description_t *chromaDesc = vlc_fourcc_GetChromaDescription(VLC_CODEC_YV12);

    Q_ASSERT(chromaDesc);

    _frame.width = *width;
    _frame.height = *height;
    _frame.planeCount = chromaDesc->plane_count;

    qDebug() << chroma << chromaDesc->plane_count << *lines;

    const unsigned int bufferSize = setPitchAndLines(chromaDesc,
                                                     *width, *height,
                                                     pitches, lines,
                                                     (unsigned *) &_frame.visiblePitch, (unsigned *)&_frame.visibleLines);
    for (unsigned int i = 0; i < _frame.planeCount; ++i) {
        _frame.pitch[i] = pitches[i];
        _frame.lines[i] = lines[i];
        _frame.plane[i].resize(pitches[i] * lines[i]);
    }

    return bufferSize;
}
void DJAdminGroupChat::sendAdminChat()
{
	QString	adminChat	= m_editor->text();
	if ( adminChat.isEmpty() )
		return;
		
	CallAdminInfo	info;
	memset( &info, 0, sizeof(CallAdminInfo) );
	info.callerId	= 0;//ignore
	info.roomId		= 0;//ignore
	info.tableId	= 0;//ignore
	info.reason		= 0;//ignore
	info.eventType	= ADMIN_CHAT_EVENT_TYPE_ADMIN_CHAT;
	
	QString		sentence;
	QTextStream	stream( &sentence, QIODevice::ReadWrite );
	stream <<info.callerId<<" "<<info.roomId<<" "<<info.tableId
			<<" "<<info.reason<<" "<<info.eventType;
	sentence.prepend("{{");
	sentence.append("}}");
	sentence.append( adminChat );
	
	QByteArray	utf8	= sentence.toUtf8();

	QByteArray	chatContent( sizeof(ChatContent) + utf8.size() + 1, 0 );
    ChatContent	*pChatContent	= reinterpret_cast<ChatContent *>(chatContent.data());
    setle4( &pChatContent->userid_speaker, m_gameController->selfUserId() );
    setle4( &pChatContent->userid_listener, m_groupId );
    pChatContent->chGameClass = 0xFF;
    pChatContent->chGame = 0xFF;
    qstrcpy( pChatContent->szSentence, utf8.data() );
    
	m_gameController->requestChat( pChatContent, chatContent.size() );
	
	m_editor->clear();
}