Example #1
0
CSession2* CBSServer::NewSessionL( const TVersion &aVersion,
                                          const RMessage2& /*aMessage*/ ) const
    {
    TRACE( T_LIT( "CBrandingServer::NewSessionL() begin") );
    TVersion srvVersion( KBSVersionMajor,
                         KBSVersionMinor,
                         KBSVersionBuild );


    if( !User::QueryVersionSupported( aVersion, srvVersion ) )
        {
        User::Leave( KErrNotSupported );
        }

    CBSSession* session = CBSSession::NewL();
    //enable backup observer
    iBackupObserver->RegisterObserver( session );
    
    TRACE( T_LIT( "CBrandingServer::NewSessionL() end session[%d] created"), session );
    return session;
    }
Example #2
0
/**
 * Function: main()
 * Description: main routine of the shell.
 * Synopsis: int main(int argc, char* argv[]) (conforms to ANSI C)
 * Return value:
 *   o An integer, indicating exit status.
 */
int
main(int argc, char* argv[])
{
	char* prompts[] =
	{
		"msh",
		"rshell",
		"rsnoop"
	};

	enum
	{
		P_MSH,
		P_RSHELL,
		P_RSNOOP
	};

	int prompt = P_MSH;

	printf
	(
		"\nWelcome to Microshell Client\nVersion: %s\nType '?' for help.\n",
		MICROSHELL_VERSION
	);

	memset(&status, 0, sizeof(sh_status_t));
	init();

	/* We loop until we get the quit signal */
	while(status.curr_signal != SH_QUIT)
	{
		char        cmdline[CMD_LINE_MAX_CHARS] = {0};
		/*sh_commands cmd_type;*/

		/* Save our state here to restart from here
		 * in case we got interrupted by a SIGALRM
		 */
		if(sigsetjmp(jmpbuf, SIGALRM))
		{
		}

		/* Prompt */
		printf("\n%s> ", prompts[prompt]);

		fgets(cmdline, CMD_LINE_MAX_CHARS, stdin);

		/* A copy of a command line for processing */
		strcpy(status.cmdline, cmdline);

		if(status.curr_signal == SH_REMOTE)
		{
			if(prompt == P_RSHELL)
				rshell(cmdline);
			else
				rsnoop(cmdline);
		}
		else
		{
			/* Parse the command line */
			status.curr_cmd = parseCmd(cmdline);

			prompt = P_MSH;

			/* Dispatch according to the command type */
			switch(status.curr_cmd)
			{
				case QUIT:
					status.curr_signal = SH_QUIT;
					/*disconnect();*/
					break;

				case SRV_RSHELL:
					/*rshell(cmdline);*/
					connectSnoopSrv(cmdline);
					prompt = P_RSHELL;
					break;

				case SRV_RSNOOP:
					/*rsnoop(cmdline);*/
					connectSnoopSrv(cmdline);
					prompt = P_RSNOOP;
					break;

				case REGISTER: /* Send connection request */

					if(status.connected == true)
						fprintf(stderr, "This client already opened a connection to the server!\n");
					else
					{
						connectTimeSrv();
						initSignals();
					}

					break;


				case SRV_VERSION: /* Send version request */

					if(status.connected == false)
						fprintf(stderr, "Server Version Request: Not connected to the server yet.\n");
					else
						srvVersion();

					break;


				case SRV_ELAPSED_TIME: /* Send eslsapsed time request */

					if(status.connected == false)
						fprintf(stderr, "Elapsed Time Request: Not connected to the server yet.\n");
					else
						srvElapsedTime();

					break;


				case SRV_TOD:/* Send time-of-the-day request */
					if(status.connected == false)
						fprintf(stderr, "Time of the Day Request: Not connected to the server yet.\n");
					else
						srvTOD();

					break;


				case PIPELINE:
					execPipeline(status.pipeline_size, -1);
					reset();
					break;


				case HELP:
					showHelp();
					break;


				case BLANK:
				case UNKNOWN: /* UNKNOWN was meant for error checking. Unused. */
					reset();
					break;


				default:
					fprintf(stderr, "msh: Unexpected command type: %d (internal error)\n", status.curr_cmd);
					exit(1);
			} /* switch(status.curr_cmd) */
		} /* !SH_REMOTE */

		/* Make sure we don't have anything in those streams */
		fflush(stdout);
		fflush(stdin);
		fflush(stderr);

	} /*  while(not QUIT) */

	exit(0);

} /* main() */