Skype Mac API-使用AppleScript还是使用5年的API? [英] Skype Mac API - Use AppleScript or 5 year old API?

查看:74
本文介绍了Skype Mac API-使用AppleScript还是使用5年的API?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个x86_64应用程序,我希望可以选择读取Skype状态消息。但是,使用5年的Skype Mac框架是32位的,如果可以在64位应用程序中进行编译,则我找不到它。

I have a x86_64 app that I would like to have optionally read Skype status messages. However, the 5 year old skype mac framework is 32-bit, and if there is a way to have that compile within a 64-bit app, I haven't found it.

我的问题是,基本上,我应该如何去做?我真的只需要获取并设置USERSTATUS AWAY / ONLINE字符串。

My question is, basically, how should I go about doing this? I really only need to get and set the USERSTATUS AWAY/ONLINE string.

使用AppleScript,每次都会弹出应Skype允许此操作对话框。这是非常低效的,非常令人讨厌。

Using AppleScript, a "Should Skype allow this" dialog pops up... every time. This is highly inefficient and downright irritating.

建议?

我正在考虑编写32位CLI包装器,但这似乎有点过头了。

I'm considering writing a 32-bit CLI wrapper, but that seems like overkill.

推荐答案

这是对Twitter要求的答复。我在回问这个问题时使用了这段代码。我不需要研究Skype API,因为它可以正常工作,但是我想它是自上次尝试使用以来已对其进行了更新。无论如何...

This is an answer in reply to a request from twitter. I used this code after asking this question way back when. I have not needed to look into the Skype API since this works just fine, but I imagine that its been updated since I last tried to use it. Anyhow...

以下是我与Skype通信时使用的NSDistributedNotifications列表:

Here's a list of the NSDistributedNotifications that I use when communicating to skype:


SKSkypeAPINotification

SKSkypeAPINotification

SKSkypeAttachResponse

SKSkypeAttachResponse

SKSkypeBecameAvailable

SKSkypeBecameAvailable

SKAvailabilityUpdate

SKAvailabilityUpdate

SKSkypeWillQuit

SKSkypeWillQuit

就像其他任何类型的NSDistributedNotification一样,您只需注册并处理结果:

Just like any other kind of NSDistributedNotification, you simply register and process the results:

[[NSDistributedNotificationCenter defaultCenter]
     addObserver:self selector:@selector(setStatusAfterQuit:) 
     name:@"SKSkypeWillQuit"
     object:nil 
     suspensionBehavior:NSNotificationSuspensionBehaviorDeliverImmediately];

这些是我不断与Skype同步的iVar:

These are the iVars that I keep to sync with Skype:

NSString *applicationName;
NSString *mostRecentStatus;
NSString *mostRecentStatusMessage;
NSString *mostRecentUsername;
int APIClientID;
BOOL isConnected;
BOOL needToSetMessage;

NSString *nextMessage;
NSString *nextStatus;

以下是如何连接Skype的示例:

Here's an example of how to connect to skype:

-(void) skypeConnect{
    if (!isConnected){
        [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"SKSkypeAPIAvailabilityRequest"                                                                     
                                                                       object:nil
                                                                     userInfo:nil        
                                                           deliverImmediately:YES];
        
        
        
        [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"SKSkypeAPIAttachRequest"
                                                                    object:applicationName
                                                                  userInfo:nil
                                                        deliverImmediately:YES];
    }
}

下面是获取状态消息的示例(在您注册后Skype):

Here's an example of getting the status message (after you've registered with Skype):

    -(void) processNotification:(NSNotification *) note{
        if ([[note name] isEqualToString:@"SKSkypeAttachResponse"]){
            
            if([[[note userInfo] objectForKey:@"SKYPE_API_ATTACH_RESPONSE"] intValue] == 0){
                NSLog(@"Failed to connect to Skype.");
                isConnected = NO;
            }else {
                NSLog(@"Connected to Skype.");
                
                APIClientID = [[[note userInfo] objectForKey:@"SKYPE_API_ATTACH_RESPONSE"] intValue];
                isConnected = YES;
                
                [self sendCommand:@"GET PROFILE MOOD_TEXT"];
                
                
                if (needToSetMessage){
                    [self sendCommand:[NSString stringWithFormat:@"SET USERSTATUS %@",nextStatus]]; 
                    [self sendCommand:[NSString stringWithFormat:@"SET PROFILE MOOD_TEXT %@",nextMessage]];
                    needToSetMessage = NO;
                    nextMessage = @"";
                    nextStatus = @"";
                }
    
            }
        
        }
    }

这篇关于Skype Mac API-使用AppleScript还是使用5年的API?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆