예제 #1
0
// -----------------------------------------------------------------------------
// CUpnpSoapMessage::ServiceType
//
// (other items were commented in a header).
// -----------------------------------------------------------------------------
//
EXPORT_C const TPtrC8 CUpnpSoapMessage::ServiceType()
{
    const TPtrC8 soap = SoapAction();
    
    if (soap.Length() > 0)
    {
        TInt servStart = soap.Find(KService());
        
        TInt servEnd = soap.Find(KCross());
        if( ( servStart < 0 ) ||
            ( servEnd   < 0 ) )
        {
            return KNullDesC8();
        }

        servStart += KService().Length();
        
        TInt length = (servEnd - servStart);
        
        return soap.Mid(servStart, length);
    }
    
    return KNullDesC8();
}
예제 #2
0
void SearchProvider::setKeys(const QStringList &keys)
{
  if (KUriFilterSearchProvider::keys() == keys)
        return;

  KUriFilterSearchProvider::setKeys(keys);

  QString name = desktopEntryName();
  if (!name.isEmpty())
      return;

  // New provider. Set the desktopEntryName.
  // Take the longest search shortcut as filename,
  // if such a file already exists, append a number and increase it
  // until the name is unique
  Q_FOREACH(const QString& key, keys)
  {
    if (key.length() > name.length())
      name = key.toLower();
  }

  const QString path (KGlobal::mainComponent().dirs()->saveLocation("services", "searchproviders/"));
  bool firstRun = true;

  while (true)
  {
    QString check(name);

    if (!firstRun)
      check += KRandom::randomString(4);

    const QString located = KStandardDirs::locate("services", "searchproviders/" + check + ".desktop");
    if (located.isEmpty())
    {
      name = check;
      break;
    }
    else if (located.startsWith(path))
    {
      // If it's a deleted (hidden) entry, overwrite it
      if (KService(located).isDeleted())
        break;
    }
  }

  setDesktopEntryName(name);
}