#include "P4Client.h"
#include "ConfigOptions.h"
#include "qperforceWindow.h"
#include "error.h"
#include <qapplication.h>
#include <qthread.h>
static ClientApi gP4Client;
Error gError;
void InitialzeClient( const char* p4Port )
{
Error err;
qDebug ("Initializing client");
gP4Client.SetPort( const_cast<char *>(p4Port) );
gP4Client.SetProtocol( "tag", "" );
gP4Client.Init( &err );
if (err.Test()) {
qDebug ("error initializing client.");
}
}
void RunP4Command( int argc, char* p[], const char* func, ClientUser* ui )
{
if (argc > 0) {
ASSERT( p != NULL );
}
ASSERT( ui != NULL );
if (!gP4Client.Dropped()) {
QApplication::setOverrideCursor( Qt::waitCursor );
// if we're not debugging, then use the gui setting, but in debug builds
// we want to see what is going on all the time.
#if !defined ( _DEBUG )
if (ConfigOptions::getInstance()->showP4Commands()) {
#endif
QString msg;
QString cmd = "p4 " + QString( func );
for (int i = 0; i < argc; ++i) {
cmd += " " + QString( p[i] );
}
// msg.sprintf( "<img src=\"img.exec\" height=12 width=12/> "
// "<b>Executing:</b><code>%s</code>",
// cmd.latin1() );
msg.sprintf( "Executing: %s", cmd.latin1() );
qperforceWindow* win = qperforceWindow::getInstance();
win->appendUserMessage( msg );
#if !defined ( _DEBUG )
}
#endif
gP4Client.SetArgv( argc, p );
gP4Client.Run( const_cast<char *>(func), ui );
QApplication::restoreOverrideCursor();
}
}