1ad7783e4SBrian Hill /* 2ad7783e4SBrian Hill * Copyright 2017, Haiku, Inc. All Rights Reserved. 3ad7783e4SBrian Hill * Distributed under the terms of the MIT License. 4ad7783e4SBrian Hill * 5ad7783e4SBrian Hill * Authors: 6*acfd5c86SBrian Hill * Brian Hill <supernova@tycho.email> 7ad7783e4SBrian Hill */ 8ad7783e4SBrian Hill 9ad7783e4SBrian Hill 10ad7783e4SBrian Hill #include "WorkingLooper.h" 11ad7783e4SBrian Hill 12ad7783e4SBrian Hill WorkingLooper(update_type action,bool verbose)13b35bccc0SBrian HillWorkingLooper::WorkingLooper(update_type action, bool verbose) 14ad7783e4SBrian Hill : 1573c2c7b4SBrian Hill BLooper("WorkingLooper"), 1673c2c7b4SBrian Hill fUpdateAction(NULL), 1773c2c7b4SBrian Hill fCheckAction(NULL), 18b35bccc0SBrian Hill fActionRequested(action), 19b35bccc0SBrian Hill fVerbose(verbose) 20ad7783e4SBrian Hill { 21ad7783e4SBrian Hill Run(); 22ad7783e4SBrian Hill PostMessage(kMsgStart); 23ad7783e4SBrian Hill } 24ad7783e4SBrian Hill 25ad7783e4SBrian Hill ~WorkingLooper()2673c2c7b4SBrian HillWorkingLooper::~WorkingLooper() 2773c2c7b4SBrian Hill { 2873c2c7b4SBrian Hill delete fUpdateAction; 2973c2c7b4SBrian Hill delete fCheckAction; 3073c2c7b4SBrian Hill } 3173c2c7b4SBrian Hill 3273c2c7b4SBrian Hill 33ad7783e4SBrian Hill void MessageReceived(BMessage * message)34ad7783e4SBrian HillWorkingLooper::MessageReceived(BMessage* message) 35ad7783e4SBrian Hill { 36ad7783e4SBrian Hill switch (message->what) { 37ad7783e4SBrian Hill case kMsgStart: 38ad7783e4SBrian Hill { 3973c2c7b4SBrian Hill if (fActionRequested == UPDATE_CHECK_ONLY) { 40b35bccc0SBrian Hill fCheckAction = new CheckAction(fVerbose); 4173c2c7b4SBrian Hill fCheckAction->Perform(); 4273c2c7b4SBrian Hill } else { 43b35bccc0SBrian Hill fUpdateAction = new UpdateAction(fVerbose); 4473c2c7b4SBrian Hill fUpdateAction->Perform(fActionRequested); 4573c2c7b4SBrian Hill } 46ad7783e4SBrian Hill break; 47ad7783e4SBrian Hill } 48ad7783e4SBrian Hill 49ad7783e4SBrian Hill default: 50ad7783e4SBrian Hill BLooper::MessageReceived(message); 51ad7783e4SBrian Hill } 52ad7783e4SBrian Hill } 53