1 // AppQuitTestApp2.cpp 2 3 #include <stdio.h> 4 5 #include <OS.h> 6 7 #include "CommonTestApp.h" 8 9 enum { 10 MSG_QUIT = 'quit', 11 }; 12 13 class Quitter : public BHandler { 14 public: 15 virtual void MessageReceived(BMessage *message) 16 { 17 if (message->what == MSG_QUIT) 18 be_app->Quit(); 19 } 20 }; 21 22 int 23 main() 24 { 25 // R5: doesn't set the error variable in case of success 26 #ifdef TEST_R5 27 status_t error = B_OK; 28 #else 29 status_t error = B_ERROR; 30 #endif 31 CommonTestApp *app = new CommonTestApp( 32 "application/x-vnd.obos-app-quit-testapp1", &error); 33 init_connection(); 34 report("error: %lx\n", error); 35 report("InitCheck(): %lx\n", app->InitCheck()); 36 app->SetReportDestruction(true); 37 if (error == B_OK) { 38 app->SetMessageHandler(new Quitter); 39 app->PostMessage(MSG_QUIT, app); 40 app->Run(); 41 } 42 delete app; 43 return 0; 44 } 45 46