Skip to content

Commit

Permalink
inital commit, das Bundle ist ladefaehig
Browse files Browse the repository at this point in the history
  • Loading branch information
Axel Schlueter committed Aug 13, 2009
0 parents commit d1b901a
Show file tree
Hide file tree
Showing 14 changed files with 1,975 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .hgignore
@@ -0,0 +1,10 @@
syntax: regexp

# die Builds gehoeren nicht ins Repo
^build/.*$

# alle dusseligen Swap-Dateien des vim ignorieren
\.swp$

# der Mac-Dreck
.DS_Store$
11 changes: 11 additions & 0 deletions BundlePrincipal.h
@@ -0,0 +1,11 @@
// Created by Axel on 13.08.09.
// Copyright 2009 __MyCompanyName__. All rights reserved.

#import <Cocoa/Cocoa.h>

@interface BundlePrincipal: NSObject {
}

+ (void)load;

@end
24 changes: 24 additions & 0 deletions BundlePrincipal.m
@@ -0,0 +1,24 @@
// Created by Axel on 13.08.09.
// Copyright 2009 __MyCompanyName__. All rights reserved.

#import "BundlePrincipal.h"
#import <syslog.h>


@implementation BundlePrincipal

+ (void)load {
// let's get some informations about our current host app
NSBundle *hostApp=[NSBundle mainBundle];
NSString *bundleID=[hostApp bundleIdentifier];
NSDictionary *infoDict=[hostApp infoDictionary];
float version=[[infoDict valueForKey:@"CFBundleVersion"] floatValue];

// write the host app info to the system log
NSString *msg=[NSString stringWithFormat:@"we were loaded for <%@>, version <%f>",bundleID,version];
openlog("vImputManager",LOG_CONS|LOG_PID,LOG_USER);
syslog(LOG_NOTICE,[msg UTF8String]);
closelog();
}

@end
Binary file added English.lproj/InfoPlist.strings
Binary file not shown.
26 changes: 26 additions & 0 deletions Info.plist
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>de.pqrs.vImputManager</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>BNDL</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>NSPrincipalClass</key>
<string>BundlePrincipal</string>
</dict>
</plist>
58 changes: 58 additions & 0 deletions doc/inputmanager.txt
@@ -0,0 +1,58 @@

Was ist ein InputManager?

- liegt als Directory in /Library/InputManagers/vImputManager/


- zwei Bestandteile, eine Property-Datei ".../vImputManager/Info"
und dann das eigentliche Cocoa Bundle ".../vImputManager/vImputManager.bundle"


- die Property-Datei ist XML:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist SYSTEM "file://localhost/System/Library/DTDs/PropertyList.dtd">
<plist version="0.9">
<dict>
<key>BundleName</key>
<string>vImputManager.bundle</string>
<key>LoadBundleOnLaunch</key>
<string>YES</string>
<key>LocalizedNames</key>
<dict>
<key>English</key>
<string>IncrementalSearch</string>
</dict>
<key>NoMenuEntry</key>
<string>YES</string>
</dict>
</plist>


- das Bundle ist ein normales Cocoa-Bundle, es sollte "+(void)load"
implementieren. Um an Infos ueber die aktuelle Host-App zu kommen
koennen wir folgendes benutzen:

[[NSBundle mainBundle] bundleIdentifier] => "com.apple.Safari"
[[NSBundle mainBundle] infoDictionary] => other information


- Beispiel-Bundle:
+ (void)load {
NSBundle *hostApp=[NSBundle mainBundle];

// check the host app is Safari
NSString *bundleID=[hostApp bundleIdentifier];
if(![bundleID isEqualToString:@"com.apple.Safari"])
return;

// check this version of Safari is supported
NSDictionary *infoDict=[hostApp infoDictionary];
float v=[[infoDict valueForKey:@"CFBundleVersion"] floatValue];
if(v<5528.16) {
// TODO: Tell the user why the plugin hasn't loaded
return;
}

// Initialise your plugin here...
}

15 changes: 15 additions & 0 deletions doc/statusbar.txt
@@ -0,0 +1,15 @@


- (void)awakeFromNib {
NSStatusBar *statusBar=[NSStatusBar systemStatusBar];

NSStatusItem *statusItem=[statusBar statusItemWithLength:NSVariableStatusItemLength];
[statusItem retain];

NSImage *itemImage = [[NSImage alloc]
initWithContentsOfFile: [[NSBundle mainBundle] pathForResource:@"icon" ofType:@"png"]];
[statusItem setImage:itemImage];
[statusItem setHighlightMode:YES];
[statusItem setMenu:tunesMenu];
}

12 changes: 12 additions & 0 deletions doc/syslogTest.c
@@ -0,0 +1,12 @@

#include <stdio.h>
#include <syslog.h>

int main(int argc,char **argv) {
openlog("axel",LOG_CONS|LOG_PID,LOG_USER);
syslog(LOG_NOTICE,"and this is another little notice");
closelog();

printf("logging done!\n");
return 0;
}
Binary file added vImputManager.xcodeproj/TemplateIcon.icns
Binary file not shown.

0 comments on commit d1b901a

Please sign in to comment.