//Sets address in the long integer form
void IPAddress::setAddressAsUnsignedLongInt(unsigned long int &ip_address)
{
	unsigned long int sweeper = 255;

	for (int i = 3; i >= 0; i--) {
		unsigned int t = ip_address & sweeper;
		address[i] = static_cast<unsigned int>(t);
		sweeper = sweeper << 8;
	}

	address[0] = address[0] >> 24;
	address[1] = address[1] >> 16;
	address[2] = address[2] >> 8;


	int jump = 24;

	for (int i = 0; i < 4; i++) {
		std::bitset<8> t(address[i]);
		for (int j = 7; j >= 0; j--) {
			binary_address[jump + j] = t[j];
		}
		jump -= 8;
	}
	setClassType(address[0]);

}
Exemple #2
0
KMobileGnokii::KMobileGnokii(QObject *obj, const char *name, const QStringList &args )
	: KMobileDevice(obj, name, args)
{
  // set initial device info
  setClassType( Phone );
  m_deviceName = i18n("Mobile Phone accessed via GNOKII");
  m_deviceRevision = "";
  m_connectionName = "/dev/ircomm0";
  setCapabilities( hasAddressBook | hasNotes );

  m_numAddresses = -1;

  // now initialize the configuration based on the
  // given config file from args[0]
  loadDeviceConfiguration();
  if (m_modelnr.isEmpty())
	loadGnokiiConfiguration();

  if (m_modelnr.isEmpty()) {
	// default communcation values
	m_modelnr = "6310";
	m_connection = "infrared";
	m_port = "/dev/ircomm0";
	m_baud = "9600";
  }

  PRINT_DEBUG << QString("Using GNOKII configuration: %1 %2 %3 %4\n").arg(m_modelnr)
		.arg(m_connection).arg(m_port).arg(m_baud);

  saveDeviceConfiguration();
  saveGnokiiConfiguration();
}
void NewClassWidget::slotBaseClassEdited(const QString &baseClass)
{
    // Set type information with some smartness.
    const ClassType currentClassType = classType();
    const ClassType recommendedClassType = classTypeForBaseClass(baseClass);
    if (recommendedClassType != NoClassType && currentClassType != recommendedClassType)
        setClassType(recommendedClassType);
}
// --------------------- NewClassWidget
NewClassWidget::NewClassWidget(QWidget *parent) :
    QWidget(parent),
    d(new NewClassWidgetPrivate)
{
    d->m_ui.setupUi(this);

    d->m_ui.baseClassComboBox->setEditable(false);

    setNamesDelimiter(QLatin1String("::"));

    connect(d->m_ui.classLineEdit, &ClassNameValidatingLineEdit::updateFileName,
            this, &NewClassWidget::slotUpdateFileNames);
    connect(d->m_ui.classLineEdit, &QLineEdit::textEdited,
            this, &NewClassWidget::classNameEdited);
    connect(d->m_ui.baseClassComboBox,
            static_cast<void (QComboBox::*)(int)>(&QComboBox::currentIndexChanged),
            this, &NewClassWidget::suggestClassNameFromBase);
    connect(d->m_ui.baseClassComboBox, &QComboBox::editTextChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.classLineEdit, &FancyLineEdit::validChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.headerFileLineEdit, &FancyLineEdit::validChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.sourceFileLineEdit, &FancyLineEdit::validChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.formFileLineEdit, &FancyLineEdit::validChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.pathChooser, &PathChooser::validChanged,
            this, &NewClassWidget::slotValidChanged);
    connect(d->m_ui.generateFormCheckBox, &QAbstractButton::toggled,
            this, &NewClassWidget::slotValidChanged);

    connect(d->m_ui.classLineEdit, &FancyLineEdit::validReturnPressed,
            this, &NewClassWidget::slotActivated);
    connect(d->m_ui.headerFileLineEdit, &FancyLineEdit::validReturnPressed,
            this, &NewClassWidget::slotActivated);
    connect(d->m_ui.sourceFileLineEdit, &FancyLineEdit::validReturnPressed,
            this, &NewClassWidget::slotActivated);
    connect(d->m_ui.formFileLineEdit, &FancyLineEdit::validReturnPressed,
            this, &NewClassWidget::slotActivated);
    connect(d->m_ui.formFileLineEdit, &FancyLineEdit::validReturnPressed,
            this, &NewClassWidget::slotActivated);
    connect(d->m_ui.pathChooser, &PathChooser::returnPressed,
             this, &NewClassWidget::slotActivated);

    connect(d->m_ui.generateFormCheckBox, &QCheckBox::stateChanged,
            this, &NewClassWidget::slotFormInputChecked);
    connect(d->m_ui.baseClassComboBox, &QComboBox::editTextChanged,
            this, &NewClassWidget::slotBaseClassEdited);
    d->m_ui.generateFormCheckBox->setChecked(true);
    setFormInputCheckable(false, true);
    setClassType(NoClassType);
}
Exemple #5
0
KMobileDevice::KMobileDevice(QObject *obj, const char *name, const QStringList &args)
	: KLibFactory(obj,name),
           m_config(0L), d(0L)
{
  setClassType(Unclassified);
  setCapabilities(hasNothing);
  m_deviceName = i18n("Unknown Device");
  m_deviceRevision = i18n("n/a");  /* not available */
  m_connectionName = i18n("Unknown Connection");

  // set the config file name
  m_configFileName = args[0];
  if (m_configFileName.isEmpty())
	m_config = new KConfig();
  else
	m_config = new KConfig(m_configFileName);
  PRINT_DEBUG << QString("name of config file is %1\n").arg(m_configFileName);
}
//Sets the IP address based on the octets passed in
void IPAddress::setAddress(int first, int second, int third, int fourth) {
	address = new unsigned int[4];

	address[0] = first;
	address[1] = second;
	address[2] = third;
	address[3] = fourth;

	int jump = 24;

	for (int i = 0; i < 4; i++) {
		std::bitset<8> t(address[i]);
		for (int j = 7; j >= 0; j--) {
			binary_address[jump + j] = t[j];
		}
		jump -= 8;
	}

	setClassType(first);
}
  UTI NodeListClassInit::checkAndLabelType()
  {
    UTI rtnuti = Node::getNodeType();

    if(m_state.okUTItoContinue(rtnuti) && m_state.isComplete(rtnuti))
      return rtnuti; //t41167,t41169

    UTI nuti = m_classUTI; //initially of-class-uti
    if(!m_state.isScalar(nuti))
      nuti = m_state.getUlamTypeAsScalar(nuti); //t41185

    if(!m_state.isComplete(nuti) || m_state.isAnonymousClass(nuti))
      {
	//incomplete, see if mapped; if so, update list
	UTI mappedUTI = nuti;
	UTI cuti = m_state.getCompileThisIdx();
	if(m_state.mappedIncompleteUTI(cuti, nuti, mappedUTI))
	  {
	    std::ostringstream msg;
	    msg << "Substituting Mapped UTI" << mappedUTI;
	    msg << ", " << m_state.getUlamTypeNameBriefByIndex(mappedUTI).c_str();
	    msg << " for incomplete initialized class type: '";
	    msg << m_state.getUlamTypeNameBriefByIndex(nuti).c_str();
	    msg << "' UTI" << nuti << " while labeling class: ";
	    msg << m_state.getUlamTypeNameBriefByIndex(cuti).c_str();
	    MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), DEBUG);
	    m_classUTI = nuti = mappedUTI;
	  }

	if(!m_state.isComplete(nuti)) //reloads to recheck for debug message
	  {
	    std::ostringstream msg;
	    msg << "Incomplete descriptor for initialized class type: ";
	    msg << m_state.getUlamTypeNameBriefByIndex(nuti).c_str();
	    MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT); //t41170
	    Node::setNodeType(Hzy);
	    m_state.setGoAgain(); //missing
	    return Hzy;
	  }
      }

    assert(m_state.okUTItoContinue(nuti) && m_state.isComplete(nuti));
    setClassType(nuti);

    rtnuti = nuti; //if all goes well..

    for(u32 i = 0; i < m_nodes.size(); i++)
      {
	assert(m_nodes[i]);
	UTI puti = m_nodes[i]->checkAndLabelType();
	if(puti == Nav)
	  {
	    std::ostringstream msg;
	    msg << "Class Init Argument " << i + 1 << " has a problem";
	    msg << " for variable " << m_state.m_pool.getDataAsString(m_classvarId).c_str();
	    msg << ", type " << m_state.getUlamTypeNameBriefByIndex(m_classUTI).c_str();
	    MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), ERR);
	    rtnuti = Nav;
	  }
	else if((rtnuti != Nav) && !m_state.isComplete(puti))
	  {
	    std::ostringstream msg;
	    msg << "Class Init Argument " << i + 1 << " is incomplete";
	    msg << " for variable " << m_state.m_pool.getDataAsString(m_classvarId).c_str();
	    msg << ", type " << m_state.getUlamTypeNameBriefByIndex(m_classUTI).c_str();
	    MSG(getNodeLocationAsString().c_str(), msg.str().c_str(), WAIT);
	    rtnuti = Hzy; // all or none
	    m_state.setGoAgain();
	  }
	//else rtnuti remains == m_classUTI
      }
    setNodeType(rtnuti);
    //    if(rtnuti == Hzy) m_state.setGoAgain(); //since no error msg
    return rtnuti;
  } //checkAndLabelType
Exemple #8
0
void CzApp::Init(bool enable_http, bool gl_conmpatible)
{
	CzGlobals::App = this;

	// Set platform callbacks
	PLATFORM_SYS->setSuspendedCallback(CzApp_DeviceSuspend);
	PLATFORM_SYS->setResumedCallback(CzApp_DeviceResume);
	PLATFORM_SYS->setVolumeUpCallback(CzApp_DeviceVolumeUp);
	PLATFORM_SYS->setVolumeDownCallback(CzApp_DeviceVolumeDown);
	PLATFORM_SYS->setNetworkOnlineCallback(CzApp_DeviceNetworkOnline);
	PLATFORM_SYS->setNetworkOfflineCallback(CzApp_DeviceNetworkOffline);

	setClassType("Game");
	GLCompatible = gl_conmpatible;
	CurrentScene = NULL;
	NextScene = NULL;
	for (int t = 0; t < CZ_MAX_TOUCHES; t++)
	{
		TouchFocus[t] = NULL;
		LastTappedActor[t] = NULL;
	}
	KeyFocus = NULL;
	TouchPanEnabled = true;
	MaxTouches = 2;
	TotalFrames = 0;
	FrameRate = 0;
	TimePaused = false;

	// Get initial screen size and orientation
	ScreenSize.x = PLATFORM_DISPLAY->getCurrentWidth();
	ScreenSize.y = PLATFORM_DISPLAY->getCurrentHeight();
	ScreenOrientation = PLATFORM_DISPLAY->getOrientation();

	// Retrieve AppEasy settings
	CzSettings::Create();
	CZ_SETTINGS->Init();

	// Initialise the http manager (only if requested and not already initialised)
	if (enable_http && CZ_HTTP_MANAGER == NULL)
	{
		CzHttpManager::Create();
		CZ_HTTP_MANAGER->Init();
	}

	// Initialise the input system
	CzInput::Create();
	CZ_INPUT->Init();

	// Initialise the rsource manager (TODO: Remove support)
	PLATFORM_OTHER->InitResManager();

	// Set default background colour
	SetBackgroundColour(0, 0, 0, 0);

	// Get initial time stamp
	LastFrameTime = PLATFORM_SYS->getTimeInMs();

	// Initialise the global resource system
	CzGlobalResources::Create();
	CZ_GLOBAL_RESOURCES->Init(this);

	// Initialise modifiers system
	CzMods::Create();
	CZ_MODS->Init();

	// Initialise programs system
	CzPrograms::Create();
	CZ_PROGRAMS->Init();

	// Init the XOML system
	CzXoml::Create();
	CZ_XOML->Init();

	// Create system array variables
	CreateSystemArray();

	// Create global UI animations
	CzUIBase::InitPresetAnimations();

	// Seed RNG
	CzMath::SeedRand((unsigned int)PLATFORM_SYS->getTimeUTC());

	// Clear the screen
	PLATFORM_DISPLAY->Clear();
}