Exemplo n.º 1
0
QContent *WheelBrowserScreen::readLauncherMenuItem(const QString &entry)
{
    QContent *applnk = 0;

    if (entry.right(8)==".desktop") {
        // There used to be a quick way to locate a .desktop file
        // Now we have to create a QContentSet and iterate over the items

        // The path to the apps folder (which only exists in the database)
        QString apps = Qtopia::qtopiaDir()+"apps/";
        // We need the full path to the entry to compare against the items we get from QContentSet
        QString entryPath = apps+entry;
        applnk = new QContent( entryPath, false );
        if ( applnk->id() == QContent::InvalidId ) {
            delete applnk;
            applnk = 0;
        }
    } else {
        QCategoryManager catman("Applications");
        if(catman.contains(entry))
        {
            applnk = new QContent();
            applnk->setName(catman.label(entry));
            applnk->setIcon(catman.iconFile(entry));
            applnk->setType("Folder/"+entry);
        }
        else
            applnk = NULL;
    }

    return applnk;
}
Exemplo n.º 2
0
void
nsDirectoryService::RegisterCategoryProviders()
{
    nsCOMPtr<nsICategoryManager> catman
        (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
    if (!catman)
        return;

    nsCOMPtr<nsISimpleEnumerator> entries;
    catman->EnumerateCategory(XPCOM_DIRECTORY_PROVIDER_CATEGORY,
                              getter_AddRefs(entries));

    nsCOMPtr<nsIUTF8StringEnumerator> strings(do_QueryInterface(entries));
    if (!strings)
        return;

    bool more;
    while (NS_SUCCEEDED(strings->HasMore(&more)) && more) {
        nsCAutoString entry;
        strings->GetNext(entry);

        nsXPIDLCString contractID;
        catman->GetCategoryEntry(XPCOM_DIRECTORY_PROVIDER_CATEGORY, entry.get(), getter_Copies(contractID));

        if (contractID) {
            nsCOMPtr<nsIDirectoryServiceProvider> provider = do_GetService(contractID.get());
            if (provider)
                RegisterProvider(provider);
        }
    }
}
Exemplo n.º 3
0
static void
resp_show(const struct req *req, const char *file)
{

	if ('.' == file[0] && '/' == file[1])
		file += 2;

	if ('c' == *file)
		catman(req, file);
	else
		format(req, file);
}
Exemplo n.º 4
0
int
main(int argc, char **argv)
{
	int c;

	__progname = argv[0];
	_wildcard(&argc, &argv);

	while ((c = getopt(argc, argv, "knpswM:")) != -1) {
		switch (c) {
		case 'k':
			f_ignerr = 1;
			break;
		case 'n':
			f_nowhatis = 1;
			break;
		case 'p':
			f_noaction = 1;
			break;
		case 's':
			f_noprint = 1;
			break;
		case 'w':
			f_noformat = 1;
			break;
		case 'M':
			mp = optarg;
			break;

		case '?':
		default:
			usage();
		}
	}

	argc -= optind;
	argv += optind;

	if (f_noprint && f_noaction)
		f_noprint = 0;

	if (argc > 1)
		usage();
	if (argc == 1)
		sp = *argv;

	if (f_noformat == 0 || f_nowhatis == 0)
		catman(mp, sp);
	if (f_nowhatis == 0 && dowhatis)
		makewhatis(mp);

	exit(0);
}
Exemplo n.º 5
0
nsresult
nsCommandLine::EnumerateHandlers(EnumerateHandlersCallback aCallback, void *aClosure)
{
  nsresult rv;

  nsCOMPtr<nsICategoryManager> catman
    (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
  NS_ENSURE_TRUE(catman, NS_ERROR_UNEXPECTED);

  nsCOMPtr<nsISimpleEnumerator> entenum;
  rv = catman->EnumerateCategory("command-line-handler",
                                 getter_AddRefs(entenum));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIUTF8StringEnumerator> strenum (do_QueryInterface(entenum));
  NS_ENSURE_TRUE(strenum, NS_ERROR_UNEXPECTED);

  nsAutoCString entry;
  bool hasMore;
  while (NS_SUCCEEDED(strenum->HasMore(&hasMore)) && hasMore) {
    strenum->GetNext(entry);

    nsCString contractID;
    rv = catman->GetCategoryEntry("command-line-handler",
				  entry.get(),
				  getter_Copies(contractID));
    if (NS_FAILED(rv))
      continue;

    nsCOMPtr<nsICommandLineHandler> clh(do_GetService(contractID.get()));
    if (!clh) {
      LogConsoleMessage(u"Contract ID '%s' was registered as a command line handler for entry '%s', but could not be created.",
                        contractID.get(), entry.get());
      continue;
    }

    rv = (aCallback)(clh, this, aClosure);
    if (rv == NS_ERROR_ABORT)
      break;

    rv = NS_OK;
  }

  return rv;
}
Exemplo n.º 6
0
nsresult
nsCommandLine::EnumerateValidators(EnumerateValidatorsCallback aCallback, void *aClosure)
{
  nsresult rv;

  nsCOMPtr<nsICategoryManager> catman
    (do_GetService(NS_CATEGORYMANAGER_CONTRACTID));
  NS_ENSURE_TRUE(catman, NS_ERROR_UNEXPECTED);

  nsCOMPtr<nsISimpleEnumerator> entenum;
  rv = catman->EnumerateCategory("command-line-validator",
                                 getter_AddRefs(entenum));
  NS_ENSURE_SUCCESS(rv, rv);

  nsCOMPtr<nsIUTF8StringEnumerator> strenum (do_QueryInterface(entenum));
  NS_ENSURE_TRUE(strenum, NS_ERROR_UNEXPECTED);

  nsAutoCString entry;
  bool hasMore;
  while (NS_SUCCEEDED(strenum->HasMore(&hasMore)) && hasMore) {
    strenum->GetNext(entry);

    nsXPIDLCString contractID;
    rv = catman->GetCategoryEntry("command-line-validator",
				  entry.get(),
				  getter_Copies(contractID));
    if (!contractID)
      continue;

    nsCOMPtr<nsICommandLineValidator> clv(do_GetService(contractID.get()));
    if (!clv)
      continue;

    rv = (aCallback)(clv, this, aClosure);
    if (rv == NS_ERROR_ABORT)
      break;

    rv = NS_OK;
  }

  return rv;
}
Exemplo n.º 7
0
int main (int argc, char **argv) {
   char *path;
   int i, result1, result2;

   /* make sure GNO is running */
   if (needsgno()==0) {
      errx(1, "Requires GNO\n");
   }

   __REPORT_STACK();

   /* initialization */
   v_flag = V_flag = M_flag = m_flag = p_flag = err_flag = 0;
   result1 = result2 = 0;

   /* parse command line and check usage */
   while((i = getopt(argc,argv,"M:m:pVv")) != EOF) {
      switch(i) {
      case 'M':
         if (m_flag) err_flag++;
         M_flag++;
         path = optarg;
         break;
      case 'm':
         if (M_flag) err_flag++;
         m_flag++;
         path = optarg;
         break;
      case 'p':
         p_flag++;
         v_flag++;
         break;
      case 'V':
         V_flag++;
         break;
      case 'v':
         v_flag++;
         break;
      default:                         
         err_flag++;
      }
   }
   if (err_flag || V_flag) {
      fprintf(stderr,"%s version %s by Devin Reade\n",
              basename(argv[0]),versionstr);
   }
   if (err_flag) {
      fprintf(stderr,"Usage: %s [-pVv] [-M path] [-m path] [section ...]\n",
              basename(argv[0]));
   }
   if (err_flag || V_flag) return 1;

   /* translate selected "sections" into something more understandable */
   for (i=optind; i<argc; i++) {
      if (!strcmp(argv[i],"local"))  argv[i] = "l";
      if (!strcmp(argv[i],"new"))    argv[i] = "n";
      if (!strcmp(argv[i],"old"))    argv[i] = "o";
      if (!strcmp(argv[i],"public")) argv[i] = "p";
   }

   /* do the search */
   if (M_flag) {
      manpath = path;
   } else {
      manpath = getManpath();
   }
   result1 = catman(argc-optind, &argv[optind]);
   if (!M_flag) free(manpath);
   if (m_flag) {
      manpath = path;
      result2 = catman(argc-optind, &argv[optind]);
   }

   return (result1 || result2);
}
Exemplo n.º 8
0
CameraMainWindow::CameraMainWindow(QWidget *parent, Qt::WFlags f):
    QMainWindow(parent, f),
    settings( NULL ),
    settingsDialog( NULL ),
    psize( -1 ),
    vsize( -1 ),
    snapRequest( 0 ),
    videoOnSecondary(false),
    m_photoContentSet( QContentSet::Asynchronous ),
    m_photoModel( 0 ),
    m_contextMenuActive(false)
{
    setWindowTitle(tr("Camera"));

    QtopiaApplication::setPowerConstraint(QtopiaApplication::DisableLightOff);

    picfile = Qtopia::tempDir() + "image.jpg";
    QWidget *cameraWidget = new QWidget(this);
    camera = new Ui::CameraBase();
    camera->setupUi(cameraWidget);
    setCentralWidget(cameraWidget);

    camcat = QLatin1String("Camera");
    // Ensure the Camera system categoy exists
    QCategoryManager catman("Documents");
    // For new code a more unique id should be used instead of using the untranslated text
    // eg. ensureSystemCategory("com.mycompany.myapp.mycategory", "My Category");
    catman.ensureSystemCategory(camcat, camcat);

    new CameraService(this);

    camera->photo->setFocus();

    connect(camera->photo, SIGNAL(clicked()), this, SLOT(takePhoto()));
    connect(camera->video, SIGNAL(clicked()), this, SLOT(toggleVideo()));

    refocusTimer = new QTimer(this);
    refocusTimer->setSingleShot(true);
    connect(refocusTimer, SIGNAL(timeout()), this, SLOT(takePhotoNow()));

    thumb[0] = camera->thumb1;
    thumb[1] = camera->thumb2;
    thumb[2] = camera->thumb3;
    thumb[3] = camera->thumb4;
    thumb[4] = camera->thumb5;
    cur_thumb = -1;

    // Load the allowable sizes from the camera hardware.
    photo_size = camera->videocaptureview->photoSizes();
    video_size = camera->videocaptureview->videoSizes();

    namehint=0;
    recording = false;


    if ( !video_supported ) {
        // Room for longer text
        camera->photo->setText(tr("Take Photo"));
        camera->video->setEnabled(false);
        camera->video->hide();
    }

    if (QApplication::desktop()->numScreens() > 1) {
        // We have a secondary display - watch for the clamshell open/close
        clamshellVsi = new QValueSpaceItem("/Hardware/Devices/ClamshellOpen", this);
        connect(clamshellVsi, SIGNAL(contentsChanged()), this, SLOT(clamshellChanged()));
        if (!clamshellVsi->value().toBool()) {
            videoToScreen(1);
        }
    }

    m_photoContentSet.setCriteria( QContentFilter( QContent::Document )
            & QContentFilter::category( QLatin1String( "Camera" ) )
            & QContentFilter::mimeType( QLatin1String( "image/jpeg" ) ) );

    m_photoContentSet.setSortCriteria( QContentSortCriteria( QContentSortCriteria::LastUpdated, Qt::DescendingOrder ) );

    m_photoModel = new QContentSetModel( &m_photoContentSet, this );
    connect( m_photoModel, SIGNAL(updateFinished()), this, SLOT(loadThumbs()) );

    m_wait = new QWaitWidget(camera->videocaptureview);
    m_iswaiting = false;
    QTimer::singleShot(1, this, SLOT(delayedInit()));
    m_currzoom = 0;
    zoomActive = false;

    zoomTimer.setSingleShot(true);
    zoomTimer.setInterval(5000);
    connect(&zoomTimer, SIGNAL(timeout()), this, SLOT(hideZoom()));
}
Exemplo n.º 9
0
static void
pg_show(const struct req *req, char *path)
{
	struct manpaths	 ps;
	size_t		 sz;
	char		*sub;
	char		 file[PATH_MAX];
	const char	*cp;
	int		 rc, catm;
	unsigned int	 vol, rec, mr;
	DB		*idx;
	DBT		 key, val;

	idx = NULL;

	/* Parse out mroot, volume, and record from the path. */

	if (NULL == path || NULL == (sub = strchr(path, '/'))) {
		resp_error400();
		return;
	} 
	*sub++ = '\0';
	if ( ! atou(path, &mr)) {
		resp_error400();
		return;
	}
	path = sub;
	if (NULL == (sub = strchr(path, '/'))) {
		resp_error400();
		return;
	}
	*sub++ = '\0';
	if ( ! atou(path, &vol) || ! atou(sub, &rec)) {
		resp_error400();
		return;
	} else if (mr >= (unsigned int)req->psz) {
		resp_error400();
		return;
	}

	/*
	 * Begin by chdir()ing into the manroot.
	 * This way we can pick up the database files, which are
	 * relative to the manpath root.
	 */

	if (-1 == chdir(req->p[(int)mr].path)) {
		perror(req->p[(int)mr].path);
		resp_baddb();
		return;
	}

	memset(&ps, 0, sizeof(struct manpaths));
	manpath_manconf(&ps, "etc/catman.conf");

	if (vol >= (unsigned int)ps.sz) {
		resp_error400();
		goto out;
	}

	sz = strlcpy(file, ps.paths[vol], PATH_MAX);
	assert(sz < PATH_MAX);
	strlcat(file, "/", PATH_MAX);
	strlcat(file, MANDOC_IDX, PATH_MAX);

	/* Open the index recno(3) database. */

	idx = dbopen(file, O_RDONLY, 0, DB_RECNO, NULL);
	if (NULL == idx) {
		perror(file);
		resp_baddb();
		goto out;
	}

	key.data = &rec;
	key.size = 4;

	if (0 != (rc = (*idx->get)(idx, &key, &val, 0))) {
		rc < 0 ? resp_baddb() : resp_error400();
		goto out;
	} else if (0 == val.size) {
		resp_baddb();
		goto out;
	}

	cp = (char *)val.data;
	catm = 'c' == *cp++;

	if (NULL == memchr(cp, '\0', val.size - 1)) 
		resp_baddb();
	else {
 		file[(int)sz] = '\0';
 		strlcat(file, "/", PATH_MAX);
 		strlcat(file, cp, PATH_MAX);
		if (catm) 
			catman(req, file);
		else
			format(req, file);
	}
out:
	if (idx)
		(*idx->close)(idx);
	manpath_free(&ps);
}