diff --git a/src/preferences/screen/ScreenMode.cpp b/src/preferences/screen/ScreenMode.cpp index 938f5282c1..ee1d3b117a 100644 --- a/src/preferences/screen/ScreenMode.cpp +++ b/src/preferences/screen/ScreenMode.cpp @@ -231,7 +231,8 @@ ScreenMode::GetOriginalMode(screen_mode& mode, int32 workspace) const { if (workspace == ~0) workspace = current_workspace(); - else if(workspace > 31) + // TODO this should use kMaxWorkspaces + else if (workspace > 31) return B_BAD_INDEX; mode = fOriginal[workspace]; diff --git a/src/preferences/screen/multimon.cpp b/src/preferences/screen/multimon.cpp index 29bcc7db93..da7e964bf5 100644 --- a/src/preferences/screen/multimon.cpp +++ b/src/preferences/screen/multimon.cpp @@ -18,10 +18,10 @@ // prepare parameters so they recognized as tunneled settings -static void PrepareTunnel( - display_mode *mode, display_mode *low, display_mode *high ) +static void +PrepareTunnel(display_mode *mode, display_mode *low, display_mode *high) { - memset( mode, 0, sizeof( *mode )); + memset(mode, 0, sizeof(*mode)); // mark modes as settings tunnel mode->space = low->space = high->space = 0; @@ -36,147 +36,151 @@ static void PrepareTunnel( // retrieve value of setting "code" -static status_t GetSetting( - BScreen *screen, uint16 code, uint32 *setting ) +static status_t +GetSetting(BScreen *screen, uint16 code, uint32 *setting) { display_mode mode, low, high; status_t result; - result = TestMultiMonSupport( screen ); - if( result != B_OK ) + result = TestMultiMonSupport(screen); + if (result != B_OK) return result; - PrepareTunnel( &mode, &low, &high ); + PrepareTunnel(&mode, &low, &high); mode.h_display_start = code; mode.v_display_start = 0; - - result = screen->ProposeMode( &mode, &low, &high ); - if( result != B_OK ) + + result = screen->ProposeMode(&mode, &low, &high); + if (result != B_OK) return result; - + *setting = mode.timing.flags; - + return B_OK; } // set setting "code" to "value" -static status_t SetSetting( - BScreen *screen, uint16 code, uint32 value ) +static status_t +SetSetting(BScreen *screen, uint16 code, uint32 value) { display_mode mode, low, high; status_t result; - - result = TestMultiMonSupport( screen ); - if( result != B_OK ) + + result = TestMultiMonSupport(screen); + if (result != B_OK) return result; - - PrepareTunnel( &mode, &low, &high ); + + PrepareTunnel(&mode, &low, &high); mode.h_display_start = code; mode.v_display_start = 1; mode.timing.flags = value; - - return screen->ProposeMode( &mode, &low, &high ); + + return screen->ProposeMode(&mode, &low, &high); } // retrieve n-th supported value of setting "code" -static status_t GetNthSupportedSetting( - BScreen *screen, uint16 code, int32 idx, uint32 *setting ) +static status_t +GetNthSupportedSetting(BScreen *screen, uint16 code, int32 idx, + uint32 *setting) { display_mode mode, low, high; status_t result; - result = TestMultiMonSupport( screen ); - if( result != B_OK ) + result = TestMultiMonSupport(screen); + if (result != B_OK) return result; - PrepareTunnel( &mode, &low, &high ); + PrepareTunnel(&mode, &low, &high); mode.h_display_start = code; mode.v_display_start = 2; mode.timing.flags = idx; - - result = screen->ProposeMode( &mode, &low, &high ); - if( result != B_OK ) + + result = screen->ProposeMode(&mode, &low, &high); + if (result != B_OK) return result; - + *setting = mode.timing.flags; - + return B_OK; } // get current Swap Displays settings -status_t GetSwapDisplays( - BScreen *screen, bool *swap ) +status_t +GetSwapDisplays(BScreen *screen, bool *swap) { status_t result; uint32 tmp; - - result = GetSetting( screen, ms_swap, &tmp ); - if( result != B_OK ) + + result = GetSetting(screen, ms_swap, &tmp); + if (result != B_OK) return result; - + *swap = tmp != 0; - + return B_OK; } // set "Swap Displays" -status_t SetSwapDisplays( - BScreen *screen, bool swap ) +status_t +SetSwapDisplays(BScreen *screen, bool swap) { - return SetSetting( screen, ms_swap, swap ); + return SetSetting(screen, ms_swap, swap); } // get current "Use Laptop Panel" settings -status_t GetUseLaptopPanel( - BScreen *screen, bool *use ) +status_t +GetUseLaptopPanel(BScreen *screen, bool *use) { status_t result; uint32 tmp; - - result = GetSetting( screen, ms_use_laptop_panel, &tmp ); - if( result != B_OK ) + + result = GetSetting(screen, ms_use_laptop_panel, &tmp); + if (result != B_OK) return result; - + *use = tmp != 0; return B_OK; } // set "Use Laptop Panel" -status_t SetUseLaptopPanel( - BScreen *screen, bool use ) +status_t +SetUseLaptopPanel(BScreen *screen, bool use) { - return SetSetting( screen, ms_use_laptop_panel, use ); + return SetSetting(screen, ms_use_laptop_panel, use); } // get n-th supported TV standard -status_t GetNthSupportedTVStandard( BScreen *screen, int idx, uint32 *standard ) +status_t +GetNthSupportedTVStandard(BScreen *screen, int idx, uint32 *standard) { - return GetNthSupportedSetting( - screen, ms_tv_standard, (int32)idx, standard ); + return GetNthSupportedSetting( + screen, ms_tv_standard, (int32)idx, standard); } // get current TV Standard settings -status_t GetTVStandard( BScreen *screen, uint32 *standard ) +status_t +GetTVStandard(BScreen *screen, uint32 *standard) { - return GetSetting( screen, ms_tv_standard, standard ); + return GetSetting(screen, ms_tv_standard, standard); } // set TV Standard -status_t SetTVStandard( BScreen *screen, uint32 standard ) +status_t +SetTVStandard(BScreen *screen, uint32 standard) { - return SetSetting( screen, ms_tv_standard, standard ); + return SetSetting(screen, ms_tv_standard, standard); } @@ -189,7 +193,7 @@ TestMultiMonSupport(BScreen *screen) uint32 count; status_t result; - // take any valid mode + // take any valid mode result = screen->GetModeList(&modeList, &count); if (result != B_OK) return result; @@ -197,7 +201,7 @@ TestMultiMonSupport(BScreen *screen) if (count < 1) return B_ERROR; - // set request bits + // set request bits modeList[0].timing.flags |= RADEON_MODE_MULTIMON_REQUEST; modeList[0].timing.flags &= ~RADEON_MODE_MULTIMON_REPLY; low = high = modeList[0]; @@ -206,7 +210,7 @@ TestMultiMonSupport(BScreen *screen) if (result != B_OK) goto out; - // check reply bits + // check reply bits if ((modeList[0].timing.flags & RADEON_MODE_MULTIMON_REQUEST) == 0 && (modeList[0].timing.flags & RADEON_MODE_MULTIMON_REPLY) != 0) result = B_OK; diff --git a/src/servers/app/Angle.cpp b/src/servers/app/Angle.cpp index 04cb17968a..609e91db41 100644 --- a/src/servers/app/Angle.cpp +++ b/src/servers/app/Angle.cpp @@ -22,7 +22,7 @@ // File Name: Angle.cpp // Author: DarkWyrm // Description: Angle class for speeding up trig functions -// +// //------------------------------------------------------------------------------ #include "Angle.h" #include @@ -62,7 +62,7 @@ Angle::~Angle() void Angle::Normalize() { - // if the value of the angle is >=360 or <0, make it so that it is + // if the value of the angle is >=360 or <0, make it so that it is // within those bounds fAngleValue = fmodf(fAngleValue, 360); if (fAngleValue < 0) @@ -87,15 +87,15 @@ Angle::Sine() Angle Angle::InvSine(float value) { - // Returns the inverse sine of a value in the range 0 <= value <= 1 via + // Returns the inverse sine of a value in the range 0 <= value <= 1 via // reverse-lookup any value out of range causes the function to return 0 - + // Filter out bad values value = fabs(value); if (value > 1) return Angle(0); - + uint16 i = 90; while (value < sSinTable[i]) i--; @@ -104,7 +104,7 @@ Angle::InvSine(float value) // to the passed value if ((value - sSinTable[i]) > (sSinTable[i + 1] - value)) return Angle(i + 1); - + return Angle(i); // value is closer to previous } @@ -127,7 +127,7 @@ Angle::Cosine(void) Angle Angle::InvCosine(float value) { - // Returns the inverse cosine of a value in the range 0 <= value <= 1 via + // Returns the inverse cosine of a value in the range 0 <= value <= 1 via // reverse-lookup any value out of range causes the function to return 0 // Filter out bad values @@ -135,7 +135,7 @@ Angle::InvCosine(float value) if (value > 1) return 0; - + uint16 i = 90; while (value > sCosTable[i]) i--; @@ -160,7 +160,7 @@ Angle::Tangent(int *status) *status = 0; return 0.0; } - + return sTanTable[(int)fAngleValue]; } @@ -177,12 +177,12 @@ Angle::InvTangent(float value) if (value > 1) return Angle(0); - + uint16 i = 90; while (value > sTanTable[i]) i--; - if( (value - sTanTable[i]) < (sTanTable[i+1] - value) ) + if ((value - sTanTable[i]) < (sTanTable[i+1] - value)) return Angle(i+1); return Angle(i); // value is closer to previous @@ -209,7 +209,7 @@ Angle::Quadrant() if (fAngleValue < 270) return 3; - + return 4; } @@ -279,13 +279,13 @@ Angle::_InitTrigTables() // Get these so that we can do some superfast assignments double sinValue = sin(currentRadian); double cosValue = cos(currentRadian); - + // Do 4 assignments, taking advantage of sin/cos symmetry sSinTable[i] = sinValue; sSinTable[i + 90] = cosValue; sSinTable[i + 180] = sinValue * -1; sSinTable[i + 270] = cosValue * -1; - + sCosTable[i] = cosValue; sCosTable[i + 90] = sinValue * -1; sCosTable[i + 180] = cosValue * -1; diff --git a/src/servers/mail/LEDAnimation.cpp b/src/servers/mail/LEDAnimation.cpp index 629851f15e..3be7d02dbf 100644 --- a/src/servers/mail/LEDAnimation.cpp +++ b/src/servers/mail/LEDAnimation.cpp @@ -1,31 +1,29 @@ + + #include "LEDAnimation.h" #include -#define SNOOZE_TIME 150000 #include -/*********************************************************** - * Constructor - ***********************************************************/ +#define SNOOZE_TIME 150000 + + LEDAnimation::LEDAnimation() - :fThread(-1) - ,fRunning(false) - ,fOrigModifiers(::modifiers()) + : + fThread(-1), + fRunning(false), + fOrigModifiers(::modifiers()) { } -/*********************************************************** - * Destructor - ***********************************************************/ + LEDAnimation::~LEDAnimation() { Stop(); } -/*********************************************************** - * Start - ***********************************************************/ + void LEDAnimation::Start() { @@ -40,9 +38,7 @@ LEDAnimation::Start() ::resume_thread(fThread); } -/*********************************************************** - * Stop - ***********************************************************/ + void LEDAnimation::Stop() { @@ -57,44 +53,39 @@ LEDAnimation::Stop() ::set_keyboard_locks(fOrigModifiers); } -/*********************************************************** - * AnimationThread - ***********************************************************/ + int32 LEDAnimation::AnimationThread(void* data) { LEDAnimation *anim = (LEDAnimation*)data; - - while (anim->fRunning) - { - LED(B_NUM_LOCK,true); + + while (anim->fRunning) { + LED(B_NUM_LOCK,true); LED(B_NUM_LOCK,false); - - LED(B_CAPS_LOCK,true); + + LED(B_CAPS_LOCK,true); LED(B_CAPS_LOCK,false); - - LED(B_SCROLL_LOCK,true); + + LED(B_SCROLL_LOCK,true); LED(B_SCROLL_LOCK,false); - - LED(B_CAPS_LOCK,true); - LED(B_CAPS_LOCK,false); + + LED(B_CAPS_LOCK,true); + LED(B_CAPS_LOCK,false); } anim->fThread = -1; return 0; } -/*********************************************************** - * LED - ***********************************************************/ + void LEDAnimation::LED(uint32 mod,bool on) { uint32 current_modifiers = ::modifiers(); - if(on) + if (on) current_modifiers |= mod; else current_modifiers &= ~mod; ::set_keyboard_locks(current_modifiers); - if(on) + if (on) ::snooze(SNOOZE_TIME); } diff --git a/src/servers/media/DefaultManager.cpp b/src/servers/media/DefaultManager.cpp index 530936c2fa..76884ac65f 100644 --- a/src/servers/media/DefaultManager.cpp +++ b/src/servers/media/DefaultManager.cpp @@ -78,7 +78,7 @@ DefaultManager::LoadState() CALLED(); status_t err = B_OK; BPath path; - if((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path))!=B_OK) + if ((err = find_directory(B_USER_SETTINGS_DIRECTORY, &path)) != B_OK) return err; path.Append(kDefaultManagerSettingsDirectory); @@ -102,7 +102,7 @@ DefaultManager::LoadState() return B_ERROR; if (file.Read(&default_type, sizeof(uint32)) < (int32)sizeof(uint32)) return B_ERROR; - if(settings.Unflatten(&file)==B_OK) { + if (settings.Unflatten(&file) == B_OK) { settings.PrintToStream(); fMsgList.AddItem(new BMessage(settings)); } @@ -131,7 +131,7 @@ DefaultManager::SaveState(NodeManager *node_manager) uint32 default_types[] = {kMsgTypeVideoIn, kMsgTypeVideoOut, kMsgTypeAudioIn, kMsgTypeAudioOut}; - uint32 media_node_ids[] = {fPhysicalVideoIn, fPhysicalVideoOut, + uint32 media_node_ids[] = {fPhysicalVideoIn, fPhysicalVideoOut, fPhysicalAudioIn, fPhysicalAudioOut}; for (uint32 i=0; iAddInt32(kDefaultManagerAddon, info.addon); settings->AddInt32(kDefaultManagerFlavorId, info.flavor_id); - settings->AddInt32(kDefaultManagerInput, + settings->AddInt32(kDefaultManagerInput, default_types[i] == kMsgTypeAudioOut ? fPhysicalAudioOutInputID : 0); settings->AddString(kDefaultManagerFlavorName, info.name); settings->AddString(kDefaultManagerPath, path.Path()); @@ -170,14 +170,14 @@ DefaultManager::SaveState(NodeManager *node_manager) for (int32 i = 0; i < category_count; i++) { BMessage *settings = (BMessage *)list.ItemAt(i); uint32 default_type; - if (settings->FindInt32(kDefaultManagerType, + if (settings->FindInt32(kDefaultManagerType, (int32*)&default_type) < B_OK) return B_ERROR; if (file.Write(&kMsgHeader, sizeof(uint32)) < (int32)sizeof(uint32)) return B_ERROR; if (file.Write(&default_type, sizeof(uint32)) < (int32)sizeof(uint32)) return B_ERROR; - if(settings->Flatten(&file) < B_OK) + if (settings->Flatten(&file) < B_OK) return B_ERROR; delete settings; } @@ -210,14 +210,14 @@ DefaultManager::Set(media_node_id node_id, const char *input_name, case AUDIO_OUTPUT: fPhysicalAudioOut = node_id; fPhysicalAudioOutInputID = input_id; - strcpy(fPhysicalAudioOutInputName, + strcpy(fPhysicalAudioOutInputName, input_name ? input_name : ""); return B_OK; case TIME_SOURCE: return B_ERROR; // called by the media_server's ServerApp::StartSystemTimeSource() - case SYSTEM_TIME_SOURCE: + case SYSTEM_TIME_SOURCE: { ASSERT(fSystemTimeSource == -1); fSystemTimeSource = node_id; @@ -304,7 +304,7 @@ DefaultManager::Get(media_node_id *nodeid, char *input_name, int32 *inputid, status_t DefaultManager::Rescan() { - thread_id fThreadId = spawn_thread(rescan_thread, "rescan defaults", + thread_id fThreadId = spawn_thread(rescan_thread, "rescan defaults", B_NORMAL_PRIORITY - 2, this); resume_thread(fThreadId); return B_OK; @@ -384,10 +384,10 @@ DefaultManager::FindPhysical(volatile media_node_id *id, uint32 default_type, int32 input_id; bool isAudio = type & B_MEDIA_RAW_AUDIO; - for(int32 i=0; iFindInt32(kDefaultManagerType, &msgType) == B_OK + if (msg->FindInt32(kDefaultManagerType, &msgType) == B_OK && ((uint32)msgType == default_type)) { const char *name = NULL; const char *path = NULL; @@ -409,10 +409,10 @@ DefaultManager::FindPhysical(volatile media_node_id *id, uint32 default_type, count = MAX_NODE_INFOS; rv = BMediaRoster::Roster()->GetLiveNodes(&info[0], &count, isInput ? NULL : &format, isInput ? &format : NULL, NULL, - isInput ? B_BUFFER_PRODUCER | B_PHYSICAL_INPUT + isInput ? B_BUFFER_PRODUCER | B_PHYSICAL_INPUT : B_BUFFER_CONSUMER | B_PHYSICAL_OUTPUT); if (rv != B_OK || count < 1) { - ERROR("Couldn't find physical %s %s node\n", + ERROR("Couldn't find physical %s %s node\n", isAudio ? "audio" : "video", isInput ? "input" : "output"); return; } @@ -428,18 +428,18 @@ DefaultManager::FindPhysical(volatile media_node_id *id, uint32 default_type, continue; } // skip the Firewire audio driver - if (0 == strcmp(info[i].name, "DV Input")) + if (0 == strcmp(info[i].name, "DV Input")) continue; } else { if (0 == strcmp(info[i].name, "None Out")) { // we keep the Null audio driver if none else matchs *id = info[i].node.node; - if(msg) + if (msg) fPhysicalAudioOutInputID = input_id; continue; } // skip the Firewire audio driver - if (0 == strcmp(info[i].name, "DV Output")) + if (0 == strcmp(info[i].name, "DV Output")) continue; } } @@ -518,14 +518,14 @@ DefaultManager::FindTimeSource() // The BeOS R5 None Out node pretend to be a physical time source, // that is pretty dumb // skip the Null audio driver - if (0 == strcmp(info[i].name, "None Out")) + if (0 == strcmp(info[i].name, "None Out")) continue; // skip the Firewire audio driver - if (0 != strstr(info[i].name, "DV Output")) + if (0 != strstr(info[i].name, "DV Output")) continue; printf("Default DAC timesource \"%s\" created!\n", info[i].name); fTimeSource = info[i].node.node; - BMediaRoster::Roster()->StartTimeSource(info[i].node, + BMediaRoster::Roster()->StartTimeSource(info[i].node, system_time() + 1000); return; } @@ -612,7 +612,7 @@ DefaultManager::ConnectMixerToOutput() for (int32 i = 0; i < count; i++) { input = inputs[i]; - if(input.destination.id == fPhysicalAudioOutInputID) + if (input.destination.id == fPhysicalAudioOutInputID) break; } diff --git a/src/servers/net/PPPServer.cpp b/src/servers/net/PPPServer.cpp index f77bc89d9c..540a1b72a6 100644 --- a/src/servers/net/PPPServer.cpp +++ b/src/servers/net/PPPServer.cpp @@ -12,9 +12,9 @@ PPPServer::PPPServer() fListener(this) { be_app->AddHandler(this); - + fListener.WatchManager(); - + InitInterfaces(); } @@ -22,9 +22,9 @@ PPPServer::PPPServer() PPPServer::~PPPServer() { UninitInterfaces(); - + fListener.StopWatchingManager(); - + be_app->RemoveHandler(this); } @@ -36,7 +36,7 @@ PPPServer::MessageReceived(BMessage *message) case PPP_REPORT_MESSAGE: HandleReportMessage(message); break; - + default: BHandler::MessageReceived(message); } @@ -61,14 +61,14 @@ void PPPServer::HandleReportMessage(BMessage *message) { ppp_interface_id id; - if(message->FindInt32("interface", reinterpret_cast(&id)) != B_OK) + if (message->FindInt32("interface", reinterpret_cast(&id)) != B_OK) return; - + int32 type, code; message->FindInt32("type", &type); message->FindInt32("code", &code); - - if(type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED) + + if (type == PPP_MANAGER_REPORT && code == PPP_REPORT_INTERFACE_CREATED) CreateConnectionRequestWindow(id); } diff --git a/src/servers/print/PrintServerApp.cpp b/src/servers/print/PrintServerApp.cpp index 3dd3023d87..dfb128d186 100644 --- a/src/servers/print/PrintServerApp.cpp +++ b/src/servers/print/PrintServerApp.cpp @@ -421,7 +421,7 @@ PrintServerApp::CreatePrinter(const char* printerName, const char* driverName, if (FindPrinterDriver(printerName, tmp) == B_OK) { if (fDefaultPrinter) { // the printer exists, but is not the default printer - if(strcmp(fDefaultPrinter->Name(), printerName) != 0) + if (strcmp(fDefaultPrinter->Name(), printerName) != 0) rc = B_OK; return rc; }