1/* 2 * Copyright 2017, Haiku, Inc. All Rights Reserved. 3 * Distributed under the terms of the MIT License. 4 * 5 * Authors: 6 * Brian Hill <supernova@tycho.email> 7 */ 8 9 10#include "WorkingLooper.h" 11 12 13WorkingLooper::WorkingLooper(update_type action, bool verbose) 14 : 15 BLooper("WorkingLooper"), 16 fUpdateAction(NULL), 17 fCheckAction(NULL), 18 fActionRequested(action), 19 fVerbose(verbose) 20{ 21 Run(); 22 PostMessage(kMsgStart); 23} 24 25 26WorkingLooper::~WorkingLooper() 27{ 28 delete fUpdateAction; 29 delete fCheckAction; 30} 31 32 33void 34WorkingLooper::MessageReceived(BMessage* message) 35{ 36 switch (message->what) { 37 case kMsgStart: 38 { 39 if (fActionRequested == UPDATE_CHECK_ONLY) { 40 fCheckAction = new CheckAction(fVerbose); 41 fCheckAction->Perform(); 42 } else { 43 fUpdateAction = new UpdateAction(fVerbose); 44 fUpdateAction->Perform(fActionRequested); 45 } 46 break; 47 } 48 49 default: 50 BLooper::MessageReceived(message); 51 } 52} 53