Flash in Applikation einbinden / E-Mail Konto anlegen

Diese Seite verwendet Cookies. Durch die Nutzung unserer Seite erklären Sie sich damit einverstanden, dass wir Cookies setzen. Weitere Informationen

  • Flash in Applikation einbinden / E-Mail Konto anlegen

    Hi,

    hat jemand eine Ahnung, wie man ein Flashmovie in ein Webview bekommt? Ich kann mich erinnern, dass es unter Applescript möglich ist, ein Flashmovie einzubinden - also sollte es unter obj-c auch möglich sein - nur wie?

    2) Hat jemand eine Ahnung, wie man ein E-Mail Konto mittels Obj-C anlegt? Unter Applescript geht das ja ziemlich einfach - für Obj-C habe ich nur ein "Account-Bundle" - d.h. mit XML gefunden - ist das die einzige Lösung?

    Vielen Dank für Eure Hilfe,

    Stefan
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • a) Einfach eine URL zum swf in den WebView packen

    b) Was Du willst, ist in der Mail.app ein neues Konto einrichten, richtig? Das geht nur über AppleScript oder die Scripting Bridge

    Alex
    The only thing that really worried me was the ether.
  • RE: Flash in Applikation einbinden / E-Mail Konto anlegen

    Original von Bosstone
    2) Hat jemand eine Ahnung, wie man ein E-Mail Konto mittels Obj-C anlegt? Unter Applescript geht das ja ziemlich einfach - für Obj-C habe ich nur ein "Account-Bundle" - d.h. mit XML gefunden - ist das die einzige Lösung?


    Wie Alex schon schrieb: AppleScript oder Scripting Bridge.
    Letztere ist (meiner Meinung nach) am Einfachsten in dein Obj-C Programm einzubauen.
    Lies dich doch mal rein. :)
    «Applejack» "Don't you use your fancy mathematics to muddle the issue!"

    Iä-86! Iä-64! Awavauatsh fthagn!

    kmr schrieb:

    Ach, Du bist auch so ein leichtgläubiger Zeitgenosse, der alles glaubt, was irgendwelche Typen vor sich hin brabbeln. :-P
  • Hi,

    jetzt bin ich etwas verzweifelt... :(

    Ich habe das ScriptingBridge.Framework in meine Application eingebunden, und trotzdem wird ScriptingBridge/ScriptingBridge.h nicht gefunden...

    Hat jemand einen Rat für mich?

    BTW - wo befindet sich mail.h?

    lg,

    Stefan

    Quellcode

    1. #import <Cocoa/Cocoa.h>
    2. #import <SystemConfiguration/SystemConfiguration.h>
    3. #import <QTKit/QTKit.h>
    4. #import <ScriptingBridge/ScriptingBridge.h>
    5. #import <ScriptingBridge/SBApplication.h>
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • Falls es jemanden interessiert: So behandelt man die Scripting Bridge:

    Introduction

    This file details the steps involved in putting together a project that uses
    Scripting Bridge to send Apple events to the System Preferences application.
    The following are the steps used to create this sample.



    1. Start with a new Cocoa application.

    In this sample we're going to use the System Preferences application so we'll
    call the sample 'SBSystemPrefs'. The techniques we are demonstrating in this
    sample can be used in any Cocoa Application. We used a simple one window Cocoa
    application for this sample to keep it simple.

    This project comes with the Interface Builder .nib file and the Controller
    object to support that already set up. It is assumed that the reader is
    familiar with those parts of Cocoa programming so the mechanics of putting those
    parts together are not discussed in this readme.




    2. Add a Scripting Bridge build rule to the project.

    The first thing to do is to set up Xcode to automatically generate the
    Scripting Bridge source for the application you would like to target. The
    following steps describe how you can do that:

    (a) Turn down the "Targets" tab in the "Groups & Files" list on the left hand
    side and select the main target. In this sample, select the "SBSystemPrefs"
    target.

    (b) With the "SBSystemPrefs" target selected, open the information panel (by
    clicking on the Info icon, or by control- or right-clicking on the target name
    and selecting "Get Info" from the pop-up menu).

    (c) In the info window, click on the Rules tab and then click on the + button
    at the bottom to add a new rule.

    (d) Set up the new rule as follows:

    Process 'Source files with names matching:' *.app

    using: 'Custom Script'

    set the script field to:

    sdef "$INPUT_FILE_PATH" | sdp -fh -o "$DERIVED_FILES_DIR" --basename
    "$INPUT_FILE_BASE" --bundleid `defaults read "$INPUT_FILE_PATH/Contents/Info"
    CFBundleIdentifier`

    click on the "+" icon below the 'with output files:' field, and then set the
    field to contain:

    $(DERIVED_FILES_DIR)/$(INPUT_FILE_BASE).h

    NOTE: if you're typing this rule in by hand, note that it should all be one
    one line, and it must be typed exactly as shown above. If you have difficulty
    entering the above command, then copy and paste the command from the readme into
    the rule.

    (e) All done. You can close the info window. Xcode is now set up to
    automatically generate Scripting Bridge source for any applications you add to
    your project.

    NOTE: this rule uses the sdef and sdp command line tools. To learn more about
    these tools, use the following commands in the Terminal window:

    man sdp
    man sdef




    3. Select a target application.

    To do this, drag and drop the application you would like to target into the
    project files group inside of the "Groups & Files" list in the project window.

    You can drop the application among the source files you are using for your
    application. Because of the build rule we added in step 2, Xcode will treat the
    System Preferences application as if it were one of the source files during the
    build.

    You should uncheck the 'Copy items into destination group's folder (if needed)'
    option so the application is not copied into your project directory. In this
    sample we have selected 'Absolute Path' as the reference type so we can easily
    move the project around from machine to machine without invalidating the
    reference (so long as the System Preferences application is present in the
    System/Library/CoreServices folder, Xcode will be able to find it).

    In this case, we are adding the System Preferences to our project. The System
    Preferences application is located in the /System/Library/CoreServices folder.




    4. Add the target application to the Compile Sources.

    After you have added the target application to your project, you must also add
    it to the main target's Compile Sources. You can do that by adding the
    application to the 'Compile Sources' build phase under the main target. In the
    "Groups & Files" list, open the "Targets" and the "SBSystemPrefs" target and
    the Compile Sources build phase items by clicking on the arrows to the left of
    them. Then, drag the System Preferences.app from the project files group into
    the Compile Sources.




    5. Add the Scripting Bridge framework to your project.

    Turn down the "Frameworks" group in the Groups & Files area, and then
    control-click (or right click) on the "Linked Frameworks" sub-group. Select
    "Add > Existing Frameworks..." from the pop-up menu. Then, add the
    "ScriptingBridge.framework"
    (/System/Library/Frameworks/ScriptingBridge.framework) to the project.




    6. Add a minimum system version Info.plist key.

    Since the ScriptingBridge.framework is necessary for this application to run
    and that framework is not present on previous system versions, you should add
    the following key/value pair to the Info.plist file for the application. If
    someone tries to run this application on a system earlier than Mac OS X 10.5,
    then they will receive a notice from launch services letting them know that the
    application is meant to be run on a later version of Mac OS X.

    <key>LSMinimumSystemVersion</key>
    <string>10.5</string>

    You can edit the Info.plist file by either clicking on its icon in the
    resources section, or by clicking on the SBSystemPrefs target, clicking on the
    Info icon, selecting the Properties tab, and then clicking on "Open Info.plist
    as File".




    7. Make sure the Target SDK is set to Mac OS X 10.5

    You won't have to change this setting for this project, but if you are adding
    Scripting Bridge to another project that you started an earlier version of the
    Mac OS than Mac OS X 10.5, then you will need to update the Target SDK for the
    project. In the Groups & Files view, select the SBSystemPrefs project icon at
    the top of the list and then open the information window. Under the General
    tab, change the Cross-Develop Using Target SDK: setting to Mac OS X 10.5.




    8. Build the project.

    If you have followed the steps above, Xcode will generate the Scripting Bridge
    source for your project. They will be put inside of your build folder in a
    place where the linker and compiler can find them.

    The build rule that we installed will create a .h file with the same name as
    the application. For example, if you added System Preferences to our project,
    then the build rule will create System Preferences.h. The files will be created
    inside of the build directory in the DerivedSources directory where the compiler
    can find them.

    For the Debug build, the System Preferences.h file will be located in this sub
    folder of the build directory:
    /build/SBSystemPrefs.build/Debug/SBSystemPrefs.build/DerivedSources/System
    Preferences.h

    For the Release build, the System Preferences.h file will be located in this
    sub folder of the build directory:
    /build/SBSystemPrefs.build/Release/SBSystemPrefs.build/DerivedSources/System
    Preferences.h

    A convenient way for you to open and inspect these files is to use the 'Open
    Quickly' command in the file menu. For most purposes, the .h file will contain
    most of the interesting information so to view that file you open the 'System
    Preferences.h' file.

    In some cases, depending on what frameworks are in your project, the 'Open
    Quickly' command may open the system's 'System Preferences.h' file that includes
    constants and definitions used by the file system and the System Preferences
    application. If that happens for you, then you will need to navigate into the
    build folder to find the correct header file.
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • Hi,

    von Apple - Homepage

    Aber ich blicke nicht durch...


    Quellcode

    1. - (void)addAccount {
    2. MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.mail"];
    3. MailAccount *account = [[[mail classForScriptingClass:@"popAccounts"] alloc]
    4. initWithProperties:
    5. [NSDictionary dictionaryWithObjectsAndKeys:
    6. passWord_1, @"password",
    7. userName1, @"userName",
    8. accountName, @"name",
    9. @"mail.lehrner.org", @"deliveryAccount",
    10. @"mail.lehrner.org", @"serverName",
    11. displayName, @"fullName",
    12. nil]];
    13. [[mail accounts] addObject: account];
    14. }
    Alles anzeigen


    Ich versuche einen Account anzulegen. Die Namen (password, userName) habe ich aus Mail.h. Mein Problem ist nun, dass ich nicht weiß, wie ich classForScriptingClass:@"xxx" benennen soll.

    In Apples Beispiel steht dort


    Quellcode

    1. /* create a new outgoing message object */
    2. MailOutgoingMessage *emailMessage =
    3. [[[mail classForScriptingClass:@"outgoing message"] alloc]
    4. initWithProperties:
    5. [NSDictionary dictionaryWithObjectsAndKeys:
    6. [self.subjectField stringValue], @"subject",
    7. [[self.messageContent textStorage] string], @"content",
    8. nil]];


    Woher nimmt Apple "outgoing message"? Bei mir ist beim Kompiling immer folgender Fehler:

    application "Mail" (not running)> has no class for scripting class "popAccounts".
    2009-07-03 14:06:59.268 m2macalizer[6175:10b] *** -[SBElementArray addObject:]: can't add an object that already exists.
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • Ich glaub, du machst da was grundlegend verkehrt - sicher bin ich mir aber nicht, da ich Mail noch nicht per ScriptingBridge gesteuert habe.

    An die Accounts kommst du via:

    Quellcode

    1. MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.mail"];
    2. id accounts = [mail popAccounts];


    Schlicht ohne irgend ein alloc, init, copy oder sonstwas.

    Einen neuen Account erstellst du afair mittels

    Quellcode

    1. [mail mailPopAccount];


    Im Allgemeinen bastelst du das mit ähnlichen Methoden wie per AppleScript.
    Wie sieht denn dein AppleScript aus? ;)
    «Applejack» "Don't you use your fancy mathematics to muddle the issue!"

    Iä-86! Iä-64! Awavauatsh fthagn!

    kmr schrieb:

    Ach, Du bist auch so ein leichtgläubiger Zeitgenosse, der alles glaubt, was irgendwelche Typen vor sich hin brabbeln. :-P
  • Original von Bosstone
    Woher nimmt Apple "outgoing message"?


    Aus dem Apple Script.

    Aus 'tell application mail create outgoing message' oder wie das heißen mag wird einfach ein
    [mail classForScriptingClass:@"outgoing message"];

    Aber man sollte schon die Methoden aus dem Header verwenden. +find+
    «Applejack» "Don't you use your fancy mathematics to muddle the issue!"

    Iä-86! Iä-64! Awavauatsh fthagn!

    kmr schrieb:

    Ach, Du bist auch so ein leichtgläubiger Zeitgenosse, der alles glaubt, was irgendwelche Typen vor sich hin brabbeln. :-P
  • Hi,

    sorry für die lange Wartezeit...

    also das Applescript sollte so aussehen:

    Quellcode

    1. set theHostname to "mail.mac.com"
    2. set theNewAccount to my createAccount(accountTypeString, theAccountName, theUsername, theHostname, thePassword, theEmailAddresses, theFullName)
    3. if (theNewAccount is equal to false) then
    4. set success to 0
    5. end if


    d.h. ich müßte eigentlich folgendes eintragen:

    Quellcode

    1. MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.mail"];
    2. MailAccount *account = [[[mail classForScriptingClass:@"createAccount"] alloc]
    3. initWithProperties:
    4. [NSDictionary dictionaryWithObjectsAndKeys:
    5. passWord_1, @"password",
    6. userName1, @"userName",
    7. accountName, @"name",
    8. @"mail.lehrner.org", @"deliveryAccount",
    9. @"mail.lehrner.org", @"serverName",
    10. displayName, @"fullName",
    11. nil]];
    12. [[mail accounts] addObject: account];
    Alles anzeigen


    d.h. bei mail classForScriptingClass - createAccount?

    Ich werde das morgen mal testen - derzeit sitze ich leider auf einer tiger machine ohne 10.5 unterstützung...

    lg und vielen dank für Eure Mühe,

    Stefan
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • Ich bin dann mal so kackfrech und lade den Header für Mail Version 3.6 (generiert mit sdp -fh -basename MailApp3) hoch, da der TE dazu ja offenbar auch nach mehrfacher Aufforderung nicht imstande ist...

    Und dazu noch folgende Hinweise:

    PHP-Quellcode

    1. ...
    2. // A Mail account for receiving messages (IMAP/POP/.Mac). To create a new receiving account, use the 'pop account', 'imap account', and 'Mac account' objects
    3. @interface MailApp3Account : MailApp3Item
    4. ...
    5. // An IMAP email account
    6. @interface MailApp3ImapAccount : MailApp3Account
    7. ...
    8. // A .Mac email account
    9. @interface MailApp3MacAccount : MailApp3ImapAccount
    10. ...
    11. // A POP email account
    12. @interface MailApp3PopAccount : MailApp3Account
    13. ...
    14. // An SMTP account (for sending email)
    15. @interface MailApp3SmtpServer : MailApp3Item
    16. ...
    Alles anzeigen
    «Applejack» "Don't you use your fancy mathematics to muddle the issue!"

    Iä-86! Iä-64! Awavauatsh fthagn!

    kmr schrieb:

    Ach, Du bist auch so ein leichtgläubiger Zeitgenosse, der alles glaubt, was irgendwelche Typen vor sich hin brabbeln. :-P
  • Hi,

    sorry für die Verzögerung! Anbei das mail.h file...

    Ich habe jetzt mal folgendes probiert:


    Quellcode

    1. - (void)addAccount {
    2. MailApplication *mail = [SBApplication applicationWithBundleIdentifier:@"com.apple.mail"];
    3. MailAccount *account = [[[mail classForScriptingClass:@"createAccount"] alloc]
    4. initWithProperties:
    5. [NSDictionary dictionaryWithObjectsAndKeys:
    6. passWord_1, @"password",
    7. userName1, @"userName",
    8. accountName, @"name",
    9. @"mail.lehrner.org", @"deliveryAccount",
    10. @"mail.lehrner.org", @"serverName",
    11. displayName, @"fullName",
    12. nil]];
    13. [[mail accounts] addObject: account];
    14. }
    Alles anzeigen


    und bekomme dann folgende Fehlermeldung:

    2009-07-06 09:25:56.497 m2macalizer[1627:10b] Host is reachable: 2
    2009-07-06 09:25:56.500 m2macalizer[1627:10b] setSettings
    2009-07-06 09:26:05.430 m2macalizer[1627:10b] MyDisplayName = ölasdflkja
    2009-07-06 09:26:05.430 m2macalizer[1627:10b] MyEmail = qasdflas
    2009-07-06 09:26:05.431 m2macalizer[1627:10b] Password 1= 12
    2009-07-06 09:26:05.431 m2macalizer[1627:10b] Password 2= 12
    m2macalizer: unknown type name "OLD message editor".
    2009-07-06 09:26:05.557 m2macalizer[1627:10b] warning: <MailApplication @0x1cbac0: application "Mail" (not running)> has no class for scripting class "createAccount".
    2009-07-06 09:26:05.558 m2macalizer[1627:10b] *** -[SBElementArray addObject:]: can't add an object that already exists.

    Ich werde jetzt mal Lucas Vorschlag ausprobieren...

    Vielen Dank für Eure Hilfe und Mühe,

    Stefan
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • jetzt wird es spannend:

    classForScriptingClass:@"pop account"

    und folgendes passiert:

    2009-07-06 09:51:27.230 m2macalizer[2008:10b] Host is reachable: 2
    2009-07-06 09:51:27.235 m2macalizer[2008:10b] setSettings
    2009-07-06 09:51:44.882 m2macalizer[2008:10b] MyDisplayName = stefan
    2009-07-06 09:51:44.882 m2macalizer[2008:10b] MyEmail = stefan@lehrner.org
    2009-07-06 09:51:44.885 m2macalizer[2008:10b] Password 1= 123
    2009-07-06 09:51:44.885 m2macalizer[2008:10b] Password 2= 123
    m2macalizer: unknown type name "OLD message editor".
    2009-07-06 09:51:45.292 m2macalizer[2008:10b] Apple event returned an error. Event = 'core'\'crel'{ 'kocl':'pact', 'insh':'insl'{ 'kobj':'obj '{ 'want':'mact', 'from':'null'(), 'form':'indx', 'seld':'abso'($206C6C61$) }, 'kpos':'end ' }, 'prdt':{ 'pnam':'utxt'("Stefan Lehrner"), 'flln':'utxt'("stefan "), 'macp':'utxt'("123"), 'host':'utxt'("mail.lehrner.org"), 'dact':'utxt'("mail.lehrner.org"), 'port':'utxt'("110"), 'unme':'utxt'("stefan@lehrner.org") } }
    Error info = {
    ErrorNumber = -10000;

    Kann mir ev. jemand erklären, welche Parameter Apple Event von mir möchte? Ich nehme an, dass ich noch mehr Infos übergeben muss als:

    Quellcode

    1. NSDictionary dictionaryWithObjectsAndKeys:
    2. passWord_1, @"password",
    3. userName1, @"userName",
    4. accountName, @"name",
    5. smtp, @"deliveryAccount",
    6. pop, @"serverName",
    7. displayName, @"fullName",
    8. port, @"port",
    9. nil]];
    Alles anzeigen



    Netterweise geht Mail nun auf - es wird zwar nichts angelegt, aber ein erster Schritt ist es schonmal ... :)

    lg,

    Stefan
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5
  • Hi,

    ich habe mein Problem nun folgendermaßen gelöst:


    Quellcode

    1. // E-Mail anlegen:
    2. {
    3. NSDictionary *scriptError = [[NSDictionary alloc] init];
    4. NSString *scriptSource = [NSString stringWithFormat:@"tell application \"Mail\"\n set %@ to make new pop account with properties {name:\"%@\", user name:\"%@\", server name:\"%@\", password:\"%@\", full name:\"%@\", email addresses:{\"%@\"}}\n end tell", account, accountName, userName1,pop, passWord_1, displayName, emailAdresse ];
    5. NSAppleScript *appleScript = [[NSAppleScript alloc] initWithSource:scriptSource];
    6. NSLog(scriptSource);
    7. NSString *setSMTP = [NSString stringWithFormat:@"tell application \"Mail\"\n set smtp server of %@ to \"%@\"", account, smtp ];
    8. NSLog(setSMTP);
    9. if(![appleScript executeAndReturnError:&scriptError])
    10. NSLog([scriptError description]);
    11. }
    Alles anzeigen


    Vielleicht nicht ganz so elegant, aber der Zweck heiligt ja bekanntlich die Mittel... :)

    lg,

    Stefan
    AlpenApps: Apps fürs Iphone aus Österreich

    ACTC - 10.5 & Troubleshooting 10.5