Пример #1
0
 std::wstring extractNameWithoutExtension(const std::wstring & pathname)
     {
     std::wstring r = extractName(pathname);
     size_t pos = r.find_last_of(L'.');
     if (pos == std::wstring::npos) { return r; }
     return r.substr(0, pos);
     }
Пример #2
0
bool pscli::EasyCLI::parse(char *input[], int size){
    if(app_name_.size() < 1)
        app_name_ = extractName(std::string(input[0]));
    
    help_->setAppName(app_name_);

    pscli::Error::initialize(app_name_);

    if(!interface_->optionExists("help")){
        interface_->addOption("help");
        interface_->setOptionHelp("help","Displays this message and quits.");
    }
    
    std::shared_ptr<LexParser> lex( new LexParser(input,size));
    SinParser sin(lex,interface_);

    bool parse_successful =  sin.parse();

    if(interface_->isOptionSet("help")){
        help_->print(*(interface_.get()));
        return false;
    }

    if(! parse_successful)
        return false;
    
    return true;
}
Пример #3
0
bool Depot::createDir(QString dirRealPath,QString login,QString password)
{
	if(!dirRealPath.startsWith(depotName) || dirRealPath==depotName) return false;
	mutex.lock();

	QString dirLocalPath=GLOBAL_DEPOTS_PATH+dirRealPath;
	QString dirParentPath=extractParentPath(dirLocalPath)+"/";
	QString dirName=extractName(dirLocalPath);
	QDir dir(dirParentPath);
	if(!dir.exists() || !dir.mkdir(dirName))
	{
		mutex.unlock();
		return false;
	}
	if(!(svnManager->addFileToDepot(GLOBAL_DEPOTS_PATH+depotName,dirLocalPath,login,password)))
	{
		mutex.unlock();
		return false;
	}
	int r=svnManager->getRevision(GLOBAL_DEPOTS_PATH+depotName);
	if(r<0)
	{
		mutex.unlock();
		return false;
	}
	revision=r;
	mutex.unlock();
	return true;
}
Пример #4
0
 std::string extractExtension(const std::string & pathname)
     {
     std::string r = extractName(pathname);
     size_t pos = r.find_last_of('.');
     if (pos == std::string::npos) { return (""); }
     return r.substr(pos + 1, std::string::npos);
     }
Пример #5
0
void TaskPacker::findName(int index) {
	for(unsigned int i = index; i < _tokens->getSize(); i++) {
		if(!_tokens->isParsed((int) i)) {
			extractName((int) i);
		}
	}
}
Пример #6
0
void testExtractName() {
  Token token;
  char text[] = "hello world", *p;

  p = text;
  token.type = TOKEN_TYPE_UNKNOWN;
  skipSpaces(&p);
  assert(extractName(&p, &token));
  assert(token.type == TOKEN_TYPE_NAME);
  assert(strcmp(token.value.string, "hello") == 0);

  token.type = TOKEN_TYPE_UNKNOWN;
  skipSpaces(&p);
  assert(extractName(&p, &token));
  assert(token.type == TOKEN_TYPE_NAME);
  assert(strcmp(token.value.string, "world") == 0);
}
Пример #7
0
MIDIDevice::MIDIDevice(MIDIInput* parent, const snd_seq_addr_t* address)
	: QObject(parent)
{
	Q_ASSERT(address != NULL);
	m_address = NULL;

	setAddress(address);
	extractName();
}
Пример #8
0
UDMXDevice::UDMXDevice(QObject* parent, struct usb_device* device)
        : QObject(parent)
{
    Q_ASSERT(device != NULL);

    m_device = device;
    m_handle = NULL;

    extractName();
}
Пример #9
0
/**
 * \fn void createPath(char *fullName, char *prefix, char *suffix, char *fileName)
 * \brief Crée un nouveau chemin pour un fichier.
 *
 * \param fullName Le chemin complet du fichier.
 * \param prefix Ce qui va etre avant le nom du fichier.
 * \param suffix Ce qui va etre apres le nom du fichier.
 * \param fileName Le nouveau chemin.
 * 
 * Exemple : 
 * fullName = Data/Test.wav
 * prefix = Results/
 * suffix = _resultat.wav
 * le nouveau chemin sera :
 * fileName = Results/Test_resultat.wav
 */
void createPath(char *fullName, char *prefix, char *suffix, char *fileName) {
	char buffer[BUFFER_SIZE] = {0};
	char nameOnly[BUFFER_SIZE];

	extractName(fullName, nameOnly);
	strcpy(buffer, prefix);
	strcat(buffer, nameOnly);
	strcat(buffer, suffix);
	strcpy(fileName, buffer);
}
Пример #10
0
MIDIDevice::MIDIDevice(MIDIInput* parent, const snd_seq_addr_t* address)
        : QObject(parent)
{
    m_address = NULL;
    m_midiChannel = 0;
    m_mbcCount = 0;

    setAddress(address);
    extractName();
    loadSettings();
}
Пример #11
0
CPO_BOOL
Reporter::init ( const char * appName,
                 const BITFIELD prefixMask,
                 const BITFIELD destination,
                 const char * path,
                 const char * file,
				 const unsigned long ulOpenAttributes)
{
  char tmpFile [ CPO_MAX_FILENAME_LEN + 1 ];
  char tmpPath [ CPO_MAX_FILENAME_LEN + 1 ];

  // must not be initialised
  if ( state & CPO_CONNECTED )
  {
    return ( CPO_FALSE );
  }

 // initialise variables
  prepare ( );
  
  // because we supplied a filename, make sure we are setup for file output
  state = destination;
  if ( ! ( state & RPT_FILE ) )
  {
    state += RPT_FILE;
  }

  // get the actual filename if a full path has been supplied
  extractName ( tmpFile, file, CPO_MAX_FILENAME_LEN );

  // add a backslash if there isn't one
  strcpy(tmpPath, path);
  if ((*(tmpPath + strlen(tmpPath) - 1)) != '\\')
	strcat(tmpPath, "\\");

  (void) sprintf ( filename, "%s%s", tmpPath, tmpFile );
  
  // final preparations
  if ( ! ( setup ( appName, prefixMask, ulOpenAttributes ) ) )
  {
    return ( CPO_FALSE );
  }

#ifdef RPT_DEBUG_PROG
    (void) fprintf ( stdout, 
                     "appname [%s] prefix %ld dest %ld file [%s] state %ld\n", 
                     appName, prefixMask, destination, filename, state );
    (void) fflush ( stdout );
#endif  
    
  InitializeCriticalSection(&aCriticalSection);
  return ( CPO_TRUE );
}
Пример #12
0
int Strings::indexOfName(const char* name) const
{
	int result = -1;

	for (int i = 0; i < getCount(); i++)
		if (compareStrings((extractName(getString(i).c_str()).c_str()), name) == 0)
		{
			result = i;
			break;
		}

	return result;
}
Пример #13
0
MIDIDevice::MIDIDevice(MIDIOut* parent, const snd_seq_addr_t* address)
        : QObject(parent)
{
    Q_ASSERT(address != NULL);
    m_address = NULL;
    m_mode = ControlChange;
    m_midiChannel = 0;

    std::fill(m_values, m_values + MAX_MIDI_DMX_CHANNELS, 0);

    setAddress(address);
    extractName();
    loadSettings();
}
Пример #14
0
PeperoniDevice::PeperoniDevice(Peperoni* parent, struct usb_device* device, quint32 line)
    : QThread(parent)
    , m_line(line)
    , m_operatingMode(CloseMode)
    , m_device(device)
    , m_handle(NULL)
{
    Q_ASSERT(device != NULL);

    /* Store fw version so we don't need to rely on libusb's volatile data */
    m_firmwareVersion = m_device->descriptor.bcdDevice;
    qDebug() << "[Peperoni] detected device firmware version:" << QString::number(m_firmwareVersion, 16);

    extractName();
}
Пример #15
0
MIDIDevice::MIDIDevice(MIDIOut* parent, UINT id) : QObject(parent)
{
	m_id = id;
	m_handle = NULL;
	m_mode = ControlChange;
	m_midiChannel = 0;
	m_isOK = false;

	/* Start with all values zeroed */
	std::fill(m_values, m_values + MAX_MIDI_DMX_CHANNELS, 0);
	
	/* Get a name for this device */
	extractName();

	/* Load global settings */
	loadSettings();
}
Пример #16
0
UDMXDevice::UDMXDevice(struct usb_device* device, QObject* parent)
    : QThread(parent)
    , m_device(device)
    , m_handle(NULL)
    , m_running(false)
    , m_universe(QByteArray(512, 0))
    , m_frequency(30)
    , m_granularity(Unknown)
{
    Q_ASSERT(device != NULL);

    QSettings settings;
    QVariant var = settings.value(SETTINGS_FREQUENCY);
    if (var.isValid() == true)
        m_frequency = var.toDouble();

    extractName();
}
CppFunction *CppFunction::create(int line, int column, const QString &fileName)
{
    const CPlusPlus::Function* fun = function(line, column, fileName );
    if (!fun)
        return 0;

    // The fun object might be destructed at any time, so we need to collect all the information.
    CppFunction* result = new CppFunction; // QtScript takes ownership
    result->m_name = extractName(fun);
    result->m_returnType = extractReturnType(fun);
    result->m_arguments = extractArguments(fun);
    result->m_isVirtual = fun->isVirtual();
    result->m_isOverride = fun->isOverride();
    result->m_isFinal = fun->isFinal();
    result->m_isVariadic = fun->isVariadic();
    result->m_isConst = fun->isConst();
    result->m_isVolatile = fun->isVolatile();
    result->m_isPureVirtual = fun->isPureVirtual();
    result->m_start = Position(fun->line(),fun->column());

    return result;
}
Пример #18
0
int loadTokens(Machine *machine, char *string) {
  skipSpaces(&string);
  while (*string != '\0') {
    Token *token;

    if (machine->tokensSize >= machine->tokensCapacity) {
      machine->tokensCapacity = 2*machine->tokensCapacity+10;
      machine->tokens =
          (Token*) realloc(machine->tokens, sizeof(Token)*machine->tokensCapacity);
    }

    token = machine->tokens+machine->tokensSize++;

    if (!(extractString(&string, token) ||
          extractNumber(&string, token) ||
          extractName(&string, token))) {
      /* Error */
      return 0;
    }

    skipSpaces(&string);
  }
  return 1;
}
Пример #19
0
/**
 * Top level function for parsing a City PML element
 * @param str Pointer to a string structure
 * @return Returns a pointer to a filled in city structure or NULL on failure
 **/
pCity cityTopLevel( pstring str )
{
	int lastGood = 0;
	pCity newCity = NULL;
	int startIndex = 0;
	int endIndex = 0;
	char *temp = NULL;
	int tempInt = 0;
	element el;

	if ( str == NULL ) {
		goto end;
	}

	/// Skip the opening "{"
	if ( skipOpen( str, 0 ) == 0 ) {
		goto end;
	}

	/// Get the start and end index of the element id
	getIndex( str, &startIndex);
	endIndex = skipAlpha(str);

	if ( endIndex == -1 ) {
		goto end;
	}

	if ( startIndex == endIndex ) {
		goto end;
	}

	temp = copyData( str, startIndex, endIndex );

	if ( temp == NULL ) {
		goto end;
	}

	if ( strcmp( temp, "City") != 0 ) {
		deallocate(temp, cgc_strlen(temp) + 1 );
		goto end;
	}

	deallocate(temp, cgc_strlen(temp) + 1 );

	skipWhiteSpace( str );
	if ( !atChar( str, '}') ) {
		goto end;
	}

	incChar( str );
	skipWhiteSpace(str);

	lastGood = str->index;

	if ( allocate( sizeof(City), 0, (void**)&newCity) != 0 ) {
		newCity = NULL;
		goto error;
	}

	initCity( newCity );

	temp = pullNextElementName( str );

	while ( temp != NULL ) {
		el = elementNameToEnum( temp );

		deallocate(temp, cgc_strlen(temp) + 1 );

		switch (el) {
			case name:
				temp = extractName( str );

				if ( temp == NULL ) {
					goto error;
				}

				/// Clear it out
				bzero( newCity->name, 20 );

				/// Copy the name data. It has already been filtered 
				///	for invalid characters.
				strncpy( newCity->name, temp, 19);

				/// Free the buffer
				deallocate( temp, cgc_strlen(temp) + 1 );
				temp = NULL;
				break;
			case mayor:
				temp = extractMayor( str );

				if ( temp == NULL ) {
					goto error;
				}
			
				bzero( newCity->mayor, 30 );
#ifdef PATCHED
				strncpy( newCity->mayor, temp, 29 );
#else
				strcpy( newCity->mayor, temp );
#endif
				freeCharPtr( &temp );

				break;
			case url:
				temp = extractUrl( str );

				if ( temp == NULL ) {
					goto error;
				}

				bzero( newCity->url, 30 );

				strncpy( newCity->url, temp, 29 );
				freeCharPtr( &temp );
				break;
			case border:
				if ( newCity->border_count >= CITYBORDERMAX) {
					goto error;
				}

				tempInt = newCity->border_count;

				newCity->borders[ tempInt ] = extractBorder(str);

				if ( newCity->borders[ tempInt] == NULL ) {
					goto error;
				}

				newCity->border_count++;
				break;
			case population:
				newCity->population = extractPopulation( str );

				if ( newCity->population < 0 ) {
					goto error;
				}

				break;
			default:
				printf("!!Invalid element ID for City\n");
				goto error;
				break;
		};

		lastGood = str->index;
		temp = pullNextElementName(str);
	}

	if ( skipOpen( str, 1) == 0 ) {
		goto error;
	}

	getIndex( str, &startIndex);
	endIndex = skipAlpha( str );

	if ( endIndex == -1 ) {
		goto error;
	} else if ( startIndex == endIndex ) {
		goto error;
	}

	temp = copyData( str, startIndex, endIndex );

	if ( temp == NULL ) {
		goto error;
	}

	if ( strcmp( temp, "City") != 0 ) {
		deallocate(temp, cgc_strlen(temp) + 1 );
		goto error;
	}

	deallocate( temp, cgc_strlen(temp) + 1 );
	skipWhiteSpace(str);
	if ( !atChar( str, '}') ) {
		goto error;
	}

	incChar(str);
	goto end;
error:
	if ( newCity ) {
		freeCity( newCity );
		newCity = NULL;
	}

	printf("!!Error at: @s\n", str->buffer + lastGood);
	str->index = lastGood;

end:
	return newCity;
}
Пример #20
0
/**
 * Parse the planet string and its sub elements
 * @param topLevel Pointer to the string structure to be parsed
 * @return Returns a pointer to a planet structure with associated data. Null on failure
 **/
pPlanet planetTopLevel( pstring topLevel )
{
	int endIndex = 0;
        int temp_index = 0;
        pPlanet newPlanet = NULL;
        element el;
        char *fl = NULL;
        int lastGood = 0;

        if ( topLevel == NULL ) {
                goto end;
        }

        /// Skip any leading spaces
        skipWhiteSpace( topLevel );

	lastGood = topLevel->index;

	if ( topLevel->maxlength < 9 ) {
		goto end;
	}

	char *c = "{Planet}";

	for ( int i = 0; i < 8; i++ ) {
		if ( topLevel->buffer[ topLevel->index + i ] != c[i] ) {
			goto end;
		}
	}

        /// Skip 8 bytes of top level then any whitespace
        topLevel->index += 8;

	skipWhiteSpace( topLevel );

        /// Allocate a new planet structure
        if ( allocate( sizeof(Planet), 0, (void**)&newPlanet) != 0 ) {
                goto end;
        }

        initPlanet( newPlanet );

        /// Extract the next element name
        fl = pullNextElementName( topLevel );

        getIndex( topLevel, &lastGood);

        while ( fl != NULL ) {
                /// Convert the element name
                el = elementNameToEnum( fl );

                /// The name is no longer needed so free it
                deallocate( fl, strlen(fl) + 1 );

                switch (el) {
                        case name:
                                fl = extractName( topLevel );

                                if ( fl == NULL ) {
                                        goto error;
                                }

				bzero( newPlanet->name, 20 );
                                strncpy( newPlanet->name, fl, 19 );

                                deallocate(fl, strlen(fl) + 1 );
                                fl = NULL;

                                break;
                        case population:
                                newPlanet->population = extractPopulation( topLevel );

                                if ( newPlanet->population < 0 ) {
                                        goto error;
                                }

                                break;
                        case period:
                                /// Extract period and check result
                                newPlanet->period = extractPeriod( topLevel );
                                if ( newPlanet->period < 0.0 ) {
                                        goto error;
                                }

                                break;
                        case orbitspeed:
                                newPlanet->orbitspeed = extractOrbitSpeed( topLevel );

                                if ( newPlanet->orbitspeed < 0.0 ) {
                                        goto error;
                                }
                                break;
                        case aphelion:
                                newPlanet->aphelion = extractAphelion( topLevel );

                                if ( newPlanet->aphelion < 0.0 ) {
                                        goto error;
                                }
                                break;
                        case perihelion:
                                newPlanet->perihelion = extractPerihelion( topLevel );

                                if ( newPlanet->perihelion < 0.0 ) {
                                        goto error;
                                }

                                break;
                        case radius:
                                newPlanet->radius = extractRadius( topLevel );

                                if ( newPlanet->radius < 0.0 ) {
                                        goto error;
                                }
                                break;

                        case eradius:
                                newPlanet->eradius = extractERadius( topLevel );

                                if ( newPlanet->eradius < 0.0 ) {
                                        goto error;
                                }
                                break;
                        case mass:
                                newPlanet->mass = extractMass( topLevel );

                                if ( newPlanet->mass < 0.0 ) {
                                        goto error;
                                }

                                break;

                        case gravity:
                                newPlanet->gravity = extractGravity( topLevel );

                                if ( newPlanet->gravity < 0.0 ) {
                                        goto error;
                                }

                                break;
                        case country:
                                if ( newPlanet->country_count >= COUNTRYMAX ) {
                                        printf("!!Only @d countries allowed\n", COUNTRYMAX);
                                        goto error;
                                }

                                newPlanet->countries[ newPlanet->country_count] = countryTopLevel(topLevel);

                                if (newPlanet->countries[ newPlanet->country_count ] == NULL ) {
                                        goto error;
                                }

                                newPlanet->country_count++;
                                break;

                        default:
                                printf("Not allowed under Planet\n", fl);
                                goto error;
                                break;
                };


                getIndex( topLevel, &lastGood );
                fl = pullNextElementName( topLevel );

        }

        /// Since no more valid elements need to be parsed, check the closing element
        skipWhiteSpace( topLevel );

        if ( !atChar( topLevel, '{' ) ) {
                printf("!!Closing value failed for Planet\n");
                goto error;
        }

        /// Skip the open brace
        if ( incChar( topLevel ) < 0 ) {
                goto error;
        }

        skipWhiteSpace( topLevel );

        if ( !atChar( topLevel, '#' ) ) {
                printf("!!Malformed closing element\n");
                goto error;
        }

        /// Skip past #
        if ( incChar( topLevel ) == -1 ) {
                goto error;
        }

        getIndex( topLevel, &temp_index );

        endIndex = skipAlpha( topLevel );

        if ( endIndex == -1 ) {
                endIndex = 0;
                goto error;
        }

        if ( temp_index == endIndex ) {
                goto error;
        }

        fl = copyData( topLevel, temp_index, endIndex );

        if ( fl == NULL ) {
                goto error;
        }

        if ( strcmp( fl, "Planet") != 0 ) {
                printf("!!Closing element malformed\n");
                deallocate( fl, (endIndex-temp_index) + 1 );
                goto error;
        }

        deallocate(fl, (endIndex-temp_index) + 1 );

        skipWhiteSpace( topLevel );

        if ( !atChar( topLevel, '}' ) ) {
                printf("!!Failed to find final closing brace\n");
                goto error;
        }

        incChar(topLevel);
	
        goto end;

error:
        topLevel->index = lastGood;

        printf("!!Error at: @s\n", topLevel->buffer + topLevel->index);

	if ( newPlanet != NULL ) {
		freePlanet( newPlanet );
		newPlanet = NULL;
	}

end:
        return newPlanet;
}
Пример #21
0
std::string Strings::getName(int index) const
{
	return extractName(getString(index).c_str());
}
Пример #22
0
void MidiEnumeratorPrivate::rescan()
{
    qDebug() << Q_FUNC_INFO;

    bool changed = false;
    QList <MidiOutputDevice*> destroyOutputs(m_outputDevices);
    QList <MidiInputDevice*> destroyInputs(m_inputDevices);

    /* Find out which devices are still present */
    ItemCount numDevices = MIDIGetNumberOfDevices();
    for (ItemCount devIndex = 0; devIndex < numDevices; devIndex++)
    {
        MIDIDeviceRef dev = MIDIGetDevice(devIndex);
        ItemCount numEntities = MIDIDeviceGetNumberOfEntities(dev);
        for (ItemCount entIndex = 0; entIndex < numEntities; entIndex++)
        {
            MIDIEntityRef entity = MIDIDeviceGetEntity(dev, entIndex);

            /* Get the entity's UID */
            QVariant uid = extractUID(entity);
            if (uid.isValid() == false)
                continue;

            QString name = extractName(entity);
            qDebug() << Q_FUNC_INFO << "Found device:" << name << "UID:" << uid.toString();

            ItemCount destCount = MIDIEntityGetNumberOfDestinations(entity);
            if (destCount > 0)
            {
                MidiOutputDevice* dev = outputDevice(uid);
                if (dev == NULL)
                {
                    CoreMidiOutputDevice* dev = new CoreMidiOutputDevice(
                        uid, name, entity, m_client, this);
                    m_outputDevices << dev;
                    changed = true;
                }
                else
                {
                    destroyOutputs.removeAll(dev);
                }
            }

            ItemCount srcCount = MIDIEntityGetNumberOfSources(entity);
            if (srcCount > 0)
            {
                MidiInputDevice* dev = inputDevice(uid);
                if (dev == NULL)
                {
                    CoreMidiInputDevice* dev = new CoreMidiInputDevice(
                        uid, name, entity, m_client, this);
                    m_inputDevices << dev;
                    changed = true;
                }
                else
                {
                    destroyInputs.removeAll(dev);
                }
            }
        }
    }

    foreach (MidiOutputDevice* dev, destroyOutputs)
    {
        m_outputDevices.removeAll(dev);
        delete dev;
        changed = true;
    }
Пример #23
0
void
AutoStart::loadAutoStartList()
{
   TQStringList files = TDEGlobal::dirs()->findAllResources("xdgconf-autostart", "*.desktop", false, true);
   TQStringList kdefiles = TDEGlobal::dirs()->findAllResources("autostart", "*.desktop", false, true);
   files += kdefiles;
   
   for(TQStringList::ConstIterator it = files.begin();
       it != files.end();
       ++it)
   {
       KDesktopFile config(*it, true);
       if (config.hasKey("X-TDE-autostart-condition")) {
           if (!startCondition(config.readEntry("X-TDE-autostart-condition")))
              continue;
       }
       else {
           if (!startCondition(config.readEntry("X-TDE-autostart-condition")))
              continue;
       }
       if (!config.tryExec())
          continue;
       if (config.readBoolEntry("Hidden", false))
          continue;

       // Check to see if the most important ( usually ~/.config/autostart or ~/.trinity/Autostart) XDG directory
       // has overridden the Hidden directive and honor it if set to True
       bool autostartOverriddenAndDisabled = false;
       for(TQStringList::ConstIterator localit = files.begin();
           localit != files.end();
           ++localit)
       {
           if (((*localit).startsWith(TDEGlobal::dirs()->localxdgconfdir()) == true) || ((*localit).startsWith(TDEGlobal::dirs()->localtdedir()) == true)) {
               // Same local file name?
               TQString localOuter;
               TQString localInner;
               int slashPos = (*it).findRev( '/', -1, TRUE );
               if (slashPos == -1) {
                   localOuter = (*it);
               }
               else {
                   localOuter = (*it).mid(slashPos+1);
               }
               slashPos = (*localit).findRev( '/', -1, TRUE );
               if (slashPos == -1) {
                   localInner = (*localit);
               }
               else {
                   localInner = (*localit).mid(slashPos+1);
               }
               if (localOuter == localInner) {
                   // Overridden!
                   // But is Hidden == True?
                   KDesktopFile innerConfig(*localit, true);
                   if (innerConfig.readBoolEntry("Hidden", false)) {
                       // Override confirmed; exit speedily without autostarting
                       autostartOverriddenAndDisabled = true;
                   }
               }
           }
       }

       if (autostartOverriddenAndDisabled == true)
           continue;

       if (config.hasKey("OnlyShowIn"))
       {
#ifdef WITH_OLD_XDG_STD
          if ((!config.readListEntry("OnlyShowIn", ';').contains("TDE")) && (!config.readListEntry("OnlyShowIn", ';').contains("KDE")))
              continue;
#else
          if (!config.readListEntry("OnlyShowIn", ';').contains("TDE"))
              continue;
#endif
       }
       if (config.hasKey("NotShowIn"))
       {
#ifdef WITH_OLD_XDG_STD
           if ((config.readListEntry("NotShowIn", ';').contains("TDE")) || (config.readListEntry("NotShowIn", ';').contains("KDE")))
               continue;
#else
           if (config.readListEntry("NotShowIn", ';').contains("TDE"))
               continue;
#endif
       }

       AutoStartItem *item = new AutoStartItem;
       item->name = extractName(*it);
       item->service = *it;
       if (config.hasKey("X-TDE-autostart-after"))
           item->startAfter = config.readEntry("X-TDE-autostart-after");
       else
           item->startAfter = config.readEntry("X-TDE-autostart-after");
       if( m_newStartup )
       {
          if (config.hasKey("X-TDE-autostart-phase"))
              item->phase = config.readNumEntry("X-TDE-autostart-phase", 2);
          else
              item->phase = config.readNumEntry("X-TDE-autostart-phase", 2);
          if (item->phase < 0)
             item->phase = 0;
       }
       else
       {
          if (config.hasKey("X-TDE-autostart-phase"))
              item->phase = config.readNumEntry("X-TDE-autostart-phase", 1);
          else
              item->phase = config.readNumEntry("X-TDE-autostart-phase", 1);
          if (item->phase < 1)
             item->phase = 1;
       }
       m_startList->append(item);
   }

   // Check for duplicate entries and remove if found
   TQPtrListIterator<AutoStartItem> it1(*m_startList);
   TQPtrListIterator<AutoStartItem> it2(*m_startList);
   AutoStartItem *item1;
   AutoStartItem *item2;
   while ((item1 = it1.current()) != 0) {
       bool dupfound1 = false;
       it2.toFirst();
       while ((item2 = it2.current()) != 0) {
           bool dupfound2 = false;
           if (item2 != item1) {
               if (item1->service == item2->service) {
                   m_startList->removeRef(item2);
                   dupfound1 = true;
                   dupfound2 = true;
               }
           }
           if (!dupfound2) {
               ++it2;
           }
       }
       if (!dupfound1) {
           ++it1;
       }
   }
}
Пример #24
0
CString RDOEditorProject::loadProject( const CString& projectName )
{
	if ( closeProject() ) {

		bool flag = true;
		bool readOnly = false;
		if ( projectName.IsEmpty() ) {
			CString s;
			s.LoadString( ID_MODEL_FILETYPE );
			CFileDialog dlg( true, "smr", lastModelPath, 0, s );
			flag = dlg.DoModal() == IDOK;
			readOnly = dlg.GetReadOnlyPref() == TRUE;
			if ( flag ) {
				extractName( dlg );
				changeLastModelPath( dlg.GetPathName() );
			}
		} else {
			extractName( projectName );
			flag = !name.IsEmpty();
			changeLastModelPath( projectName );
		}

		if ( flag ) {

			CString fName;
			RDOEditorTabCtrl* tabCtrl = &((RDOEditorMainFrame*)AfxGetMainWnd())->childView.tab;

			bool wasError = false;

			for ( int i = 0; i < tabCtrl->getItemCount(); i++ ) {
				RDOEditorEdit* edit = tabCtrl->getItemEdit( i );
				edit->setReadOnly( false );
				edit->clearAll();

				fName = modelFileName;
				bool canLoad  = true;
				bool mustExis = false;
				switch ( i ) {
					case RDOEDIT_PAT: fName += ".pat"; break;
					case RDOEDIT_RTP: fName += ".rtp"; break;
					case RDOEDIT_RSS: fName += ".rss"; break;
					case RDOEDIT_OPR: fName += ".opr"; break;
					case RDOEDIT_FRM: fName += ".frm"; break;
					case RDOEDIT_FUN: fName += ".fun"; break;
					case RDOEDIT_SMR: fName += ".smr"; mustExis = true; break;
					case RDOEDIT_DPT: fName += ".dpt"; break;
					case RDOEDIT_PMD: fName += ".pmd"; break;
					default: canLoad = false;
				}

				if ( canLoad ) {
					wasError |= !loadFile( fName, edit, mustExis );
					edit->setReadOnly( readOnly );
				}

				edit->setCurrentPos( 0 );
				edit->setModifyFalse();
			}
			if ( !wasError ) {
				return modelFileName;
			} else {
				CString s;
				s.LoadString( ID_MSG_MODELOPEN_ERROR );
				AfxGetMainWnd()->MessageBox( s, NULL, MB_ICONSTOP | MB_OK );
				setName( "" );
			}
		}
	}
	return "";
}