How to get icon for network computer ( smb/afp ) on macOS based on type - objective-c

Is it possible to get icon for network computer/ip address under macOS so iMac has iMac icon etc?
I am using NSNetServiceBrowser to get available services, but I do not know how to get icon like official Finder app does. Finder recognize icons for iMac, MacBookPro etc. Thanks.

I don't have a working solution for you, but I see your question didn't get much attention yet so maybe I can point you in the right direction.
Finder looks for services, and it will check if found services have "device info" associated with them. This is done via Bonjour, looking for a _device-info._tcp pseudo service. A lookup for a device info may return a Bonjour TXT record that indicates the model ID of the gizmo. If Finder succeeds in getting this info, then it assigns an icon accordingly, otherwise, it picks a generic icon.
The icons themselves seem to be stored here: /System/Library/CoreServices/CoreTypes.bundle (at least on my 10.13 machine). Check the Info.plist on that bundle, and the other bundles contained within, and you can find mappings between device types and icons.
There are some posts talking about how to customise the icon that's shown for certain devices:
Add custom network device icons in Mac OS X Finder?
Can you use Bonjour for Windows to broadcast a different icon than the Bluescreen?
I tried to follow the steps in this post to examine the model names advertised by some Apple hardware on my network, but couldn't make it work (either using the dig tool or with NSNetService) (although I admit I didn't try very hard with NSNetService as I'm not familiar with it).
This thread discusses potential problems and solutions, however the dig tool wouldn't work for me despite having both SMB and AFP over TCP enabled.
All of these threads are fairly old, although the commentary in the linked SO post suggest this still works at least as of Sierra.
Good luck!

Related

iPadOS USB Volume Control knob interaction programatically

I am working on a non-audio app for iOS and iPadOS and macOS. This question is specifically about iPadOS for now.
I purchased a generic "USB Volume Control" knob device. I am able to plug it into my (non M1) iPad Pro 12.9 and it does indeed control system volume (rotate), as well as things like rotate through tracks in the Music app (push and rotate), mute (push), etc. I have a second such device from another manufacturer on the way to test with as well.
What I'd really like to do is use it in a non-music context. To be able to capture the raw actions and interpret them in my app's subject domain (DCC model train control).
I have been able, on iPadOS but not iOS [as it doesn't have generic USB support as I understand it] to capture the volume changes by using AVAudioSession and KVO tracking the outputVolume property. I haven't yet figured out how to get the push and push-rotate yet but assume I just need to find the analogue functions in AVAudioSession or some other Apple class.
But I would rather not dink around with the Audio/Music classes and have to "re-purpose" them into my own control needs and was wondering if anyone knew of a way to be able to find and connect to the device and get the values directly.
As iPadOS now has pretty good generic USB support for all sorts of devices, I am hoping there is a way for me to provide service to/with/from those devices but I can't find information through normal internet searches. Poor Google-fu.
I looked at the External Accessory framework but my understanding is that only for MFi certified devices and my attempts to detect the devices have not worked as these are generic USB devices. (Unless there are generic protocols one can register for and make this work).
Thanks for any hints, pointers, admonishments, etc. RTFM is welcome if you tell me the M.

Applying Non-Standard Power Assertions & Creating Virtual HIDs

I've got a big ask here, but I am hoping someone might be able to help me. If there's another site you think this should be posted on, please let me know.
I'm the developer of the free app Amphetamine for macOS and I'm hoping to add a new feature to the app - keeping a Mac awake while in closed-display (clamshell) mode while not having a keyboard/mouse/power adapter/display connected to the Mac. I get requests to add this feature on an almost daily basis.
I've been working on a solution (and it's mostly ready) which uses a non-App Store helper app that must be download and installed separately. I could still go with that solution, but I want to explore one more option before pushing the separate app solution out to the world.
An Amphetamine user tipped me off that another app, AntiSleep can keep a Mac awake while in closed-display mode, while not meeting Apple's requirements. I've tested this claim, and it's true. After doing a bit of digging into how AntiSleep might be accomplishing this, I've come up with 2 possible theories so far (though there may be more to it):
In addition to the standard power assertion types, it looks like AntiSleep is using (a) private framework(s) to apply non-standard power assertions. The following non-standard power assertion types are active when AntiSleep is keeping a Mac awake: DenySystemSleep, UserIsActive, RequiresDisplayAudio, & InternalPreventDisplaySleep. I haven't been able to find much information on these power assertion types beyond what appears in IOPMLibPrivate.h. I'm not familiar at all with using private frameworks, but I assume I could theoretically add the IOPMLibPrivate header file to a project and then create these power assertion types. I understand that would likely result in an App Store review rejection for Amphetamine, of course. What about non-App Store apps? Would Apple notarize an app using this? Beyond that, could someone help me confirm that the only way to apply these non-standard power assertions is to use a private framework?
I suspect that AntiSleep may also be creating a virtual keyboard and mouse. Certainly, the idea of creating a virtual keyboard and mouse to get around Apple's requirement of having a keyboard and mouse connected to the Mac when using closed-display mode is an intriguing idea. After doing some searching, I found foohid. However, I ran into all kinds of errors trying to add and use the foohid files in a test project. Would someone be willing to take a look at the foohid project and help me understand whether it is theoretically possible to include this functionality in an App Store compatible app? I'm not asking for code help with that (yet). I'd just like some help determining whether it might be possible to do.
Thank you in advance for taking a look.
Would Apple notarize an app using this?
I haven't seen any issues with notarising code that uses private APIs. Currently, Apple only seems to use notarisation for scanning for inclusion of known malware.
Would someone be willing to take a look at the foohid project and help me understand whether it is theoretically possible to include this functionality in an App Store compatible app?
Taking a quick glance at the code of that project, it's clear it implements a kernel extension (kext). Those are not allowed on the App Store.
However, since macOS 10.15 Catalina, there's a new way to write HID drivers, using DriverKit. The idea is that the APIs are very similar to the kernel APIs, although I suspect it'll be a rewrite of the kext as a DriverKit driver, rather than a simple port.
DriverKit drivers are permitted to be included in App Store apps.
I don't know if a DriverKit based HID driver will solve your specific power management issue.
If you go with a DriverKit solution, this will only work on 10.15+.
I suspect that AntiSleep may also be creating a virtual keyboard and mouse.
I haven't looked at AntiSleep, but I do know that in addition to writing an outright HID driver, it's possible to generate HID events using user space APIs such as IOHIDPostEvent(). I don't know if those are allowed on the App Store, but as far as I'm aware, IOKitLib is generally fine.
It's possible you might be able to implement your virtual input device using those.

Camera compatibility

I have an usb-camera with its drivers and dll with some functions to use this camera in my solutions. I want to use it in any wide-spread applications, to be able just to choose and use it in Skype, for instance. So. I want to develop something that will allow me to use this device as usual web-camera.
I've heard something about such technologies as "Upper-Level Filter Drivers" and "user-mode DirectShow source filter". Looks like it something that can help.
So the question is: what technologies exist for such tasks? What technology should I choose to solve my problem if I have no skills of driver development?
Skype still uses DirectShow for video capture and user mode filter will do the job. Still Skype makes certain unreasonable assumptions that limit compatible source filters, such as if the developers stopped development/testing as soon as they had their favorite USB cam working and ignoring all other devices users might possibly want to attach.
One of the options you were suggested (in Russian - 1, 2) was to develop a kernel mode driver so that your device is visible to apps through standard WDM Video Capture Filter. This is possible and would work, though in my opinion it is a huge overkill.
Fitting custom source filter is not easy because Skype does not like a debugger attached, however driver development is really a completely different story.
The Skype Forum link you refer to is clearly misleading. The poster complains that Skype update broke compatibility with video sources. And response from admin is about audio devices, and is irrelevant.

AirPlay API for Mac OS X

Is there currently any API (public or private) that will allow a 3rd party Mac OS X application to stream audio to AirPlay receivers? Airfoil by Rogue Amoeba Software seems to be able to do this, same goes for Erica Sadun's AirFlick, but I was unable to find any source code that would demonstrate how to do this. Any pointers are appreciated!
Here is an open source ruby implementation. It's pretty straight forward. https://github.com/elcuervo/airplay
It turns out AirPlay audio streaming is possible as of OS X 10.8 using public APIs, but wasn't really documented anywhere. Joris Kluivers wrote a great blog post on how to get it going.
There are a couple of open-source RAOP players available; I haven't tried them, so I don't know if Apple has broken them since they were written.
Mountain Lion (OS X 10.8) has added AirPlay support in the sound settings. The user can choose to send the local sound output to an AirPlay device. However, I don't think that you have access to any API within your app.
There are some libraries available to implement AirPlay, but know that Apple will reject your app if you try to publish it on the App Store. At least, that's what happened to me.
I wrote a node.js module to support AirPlay. Even if you don't use node, you can just pipe your audio data through stdin.
https://github.com/lperrin/node_airtunes/
I don't think it's available. At least not in versions prior to 10.7.
I'm guessing that Airfoil uses something like DVD John did a while ago when he cracked the Airport Express key payload. He released the code (C#) you should be able to find it but it's pretty cryptic.
I'm not aware of what AirFlick uses but you could always try pinging Erica, she usually shares her stuff.
Someone recently managed to obtain the AirPlay private key which allows you to have your program listed in the AirPlay menus on devices on your network.
You can read about it here. There is also an open source project linked from that page.
http://mafipulation.org/blagoblig/2011/04/08#shairport
Be aware that obviously any application you create will never be approved by apple and the private key could potentially be changed in a firmware/software update.

SAM-BA not responding with olimex sam7s256

I am using an Olimex sam7s256 board. I tried to get it up and running in linux (Ubuntu). I was able to successfully install GCC and binutils. I installed SAM-BA for linux from the atmel site. I was able to get the USB port for connection as specified in the SAM-BA manual (.dev/ttyUSB0).
But when I try to use the GUI and 'connect' there is no response.
I though that there is a connection failure, so when I presses the reset button in the board, I get a message "Failed to initialize FLASH accesses".
No matter how long I wait before pressing the reset button, I am not getting any SAM-BA window as given by other tutorials as below
can any one one help me out in this?
I did the 'tst' jumper set, reconnect the board for 10 s, disconnect and 'tst' jumper reset, reconnect before opening SAM-BA.
Any help will be greatly appreciated.
I am stuck.
It is the same for both SAM-BA 2.9 and 2.8.
By this point you are already connected. If you specified the at91sam7256-ek even if you arent using that board it will not put this gui up if it didnt talk to the chip/board. I recently went through this exercise with an olimex sam7s-256 header board. (with ubuntu linux). If I didnt specify the board type then the window came up but it wasnt really connected.
Notice how the code at 0x00200000 is valid instructions (most start with a 0xE and the vector table starts with a bunch of 0xEAs which are branches out of the vector table) that is ram it didnt make those up it read that from somewhere. Load a binary file into ram in the 0x00200000 range and the refresh the memory (assuming your binary is different from what is there) and see it change.
When ready/comfortable you can erase the flash and see in the memory window that the flash (0x0010000 or something like that) changes to all 0xFFFFFFFFs. Now remember it wont boot when you do that. With the board I have there is a jumper you move then power the board to get the built in bootloader re-loaded into the flash so that you can use sam-ba again, I am sure there is a way to do that with your board but read the users guide first.
Please do not close this person out for asking about using a software tool. There are countless numbers of how do I use my iphone simulator or why is my android simulator slower than my iphone simulator questions that dont get touched. this question is as relevant as any of the programming questions about how to use gcc or some web thing or how to start up my phone simulator or java vm. I wouldnt want to have to start a campaign to close all of the gcc or iphone tagged questions because they are not programming questions.
I think my question was misunderstood. The GUI window which I have posted is NOT what I get. I just posted it to say that I am not getting such a window at all. That window pops up only when I select 'no board'. When I select SAM7S256-EK there is no response. No window opens. As given in your blog sam7stuff.blogspot.com, I downloaded SAM-BA. The onlydifference as u have posted and in the response also id that u are using a 'h' board.
Right now I am using a custom made SAMBA alternative from this website,
http://claymore.engineer.gvsu.edu/~steriana/Software/
It is also a python based boot loader. It is command line though.
I would love to use the SAM-BA GUI. I am sure that the board is OK and samba is communicating with the board b'cos if I select any other board type other than ARM7S256-EK option it is giving me 'communication failure'.
If you have any suggestions please do let me know. Also many thanks for backing me up. I had some real good insights from this forum about embedded field and I felt it is a good place to discuss embedded programming doubts and never thought of 'programming' or 'non-programming' b'cos for SAM-BA user guide itself talks a lot about customizing the SAM-BA for a custom made board involving TCL scripts but I couldnot get hold of the concepts. So I thought someone would have had the same problem and would have found a TCL or C 'programming' solutions in this forum.
Thank you.