Permalink
Browse files

Remove "computer" from default sleep quit message and use actual mode…

…l. For Alex.
  • Loading branch information...
1 parent 2f8e5f7 commit 18c34b308ff450967f993d9971c00ca295236935 @emsquared emsquared committed Mar 8, 2013
@@ -91,7 +91,7 @@ - (id)init
self.realname = [TPCPreferences defaultRealname];
self.normalLeavingComment = TXTLS(@"DefaultDisconnectQuitMessage");
- self.sleepModeLeavingComment = TXTLS(@"OSXGoingToSleepQuitMessage");
+ self.sleepModeLeavingComment = TXTFLS(@"OSXGoingToSleepQuitMessage", [CSFWSystemInformation systemModelName]);
}
return self;
@@ -44,5 +44,7 @@
+ (NSString *)systemStandardVersion;
+ (NSString *)systemOperatingSystemName;
++ (NSString *)systemModelName; // "iMac," "MacBook," "MacBook Pro," etc.
+
+ (NSString *)retrieveSystemInformationKey:(NSString *)key;
@end
@@ -37,6 +37,8 @@
#import "SystemInformation.h"
+#include <sys/sysctl.h>
+
@implementation CSFWSystemInformation
#pragma mark -
@@ -60,6 +62,55 @@ + (NSString *)systemOperatingSystemName
#pragma mark -
#pragma mark Private.
++ (NSString *)systemModelToken
+{
+ char modelBuffer[256];
+
+ size_t sz = sizeof(modelBuffer);
+
+ if (sysctlbyname("hw.model", modelBuffer, &sz, NULL, 0) == 0) {
+ modelBuffer[(sizeof(modelBuffer) - 1)] = 0;
+
+ return @(modelBuffer);
+ }
+
+ return nil;
+}
+
++ (NSString *)systemModelName
+{
+ /* This method is not returning very detailed information. Only
+ the model being ran on. Therefore, not much love will be put into
+ it. As can be seen below, we are defining our models inline instead
+ of using a dictionary that will have to be loaded from a file. */
+
+ NSDictionary *modelPrefixes = @{
+ @"macbookpro" : @"MacBook Pro",
+ @"macbookair" : @"MacBook Air",
+ @"macbook" : @"MacBook",
+ @"macpro" : @"Mac Pro",
+ @"macmini" : @"Mac Mini",
+ @"imac" : @"iMac",
+ @"xserve" : @"Xserve"
+ };
+
+ NSString *modelToken = [self systemModelToken];
+
+ if (modelToken.length <= 0) {
+ return nil;
+ }
+
+ modelToken = modelToken.lowercaseString;
+
+ for (NSString *modelPrefix in modelPrefixes) {
+ if ([modelToken hasPrefix:modelPrefix]) {
+ return modelPrefixes[modelPrefix];
+ }
+ }
+
+ return nil;
+}
+
+ (NSString *)retrieveSystemInformationKey:(NSString *)key
{
NSDictionary *sysinfo = [self systemInformationDictionary];
View
@@ -48,8 +48,8 @@
<key>TXBundleBuildCodeName</key>
<string>Mud Pie</string>
<key>TXBundleBuildNumber</key>
- <string>15233</string>
+ <string>15237</string>
<key>TXBundleBuildReference</key>
- <string>3.0.0b3-254-ga382c7b-stdbuild</string>
+ <string>3.0.0b3-255-g2f8e5f7-stdbuild</string>
</dict>
</plist>
@@ -210,7 +210,7 @@
"NotificationInvitedMessageDescription" = "%1$@ has invited you to %2$@";
"NotificationKickedMessageDescription" = "%1$@ has kicked you out: %2$@";
-"OSXGoingToSleepQuitMessage" = "Computer has gone to sleep.";
+"OSXGoingToSleepQuitMessage" = "My %@ has gone to sleep. ZZZzzz…";
"OkButton" = "OK";

0 comments on commit 18c34b3

Please sign in to comment.