BenoitDuffez / AndroidCupsPrint

Port of cups4j to Android. Allows wireless printing from any Android device to any CUPS-enabled print server or network printer.
https://benoitduffez.github.io/AndroidCupsPrint
GNU Lesser General Public License v3.0
228 stars 66 forks source link

"Couldn't find job #, is it already finished?" after each Job #188

Open mxre opened 3 years ago

mxre commented 3 years ago

Each time I submit a print job a get the Popup "Couldn't find job #, is it already finished?" (I use a HTTPS CUPS server with HTTP Authentication)

I think the reason for this message is that CupsService.kt:237 (updateJobStatus) and CupsService.kt:278 (getJobState) use CUPS unauthenticated to send the Get-Job-Attributes request to the CUPS server, which answers with 401 (I checked this with wireshark)

(Btw, Printing works perfectly it's more of a cosmetic thing)

newhinton commented 3 years ago

I think your assumption is not quite right, from analysing the code i think the stack is roughly this:

CupsService.getJobState -> CupsClient.getJobAttributes() -> IppGetJobAttributesOperation(context).getPrintJobAttributes(url, userName, jobID) -> IppOperation.request() -> IppOperation.sendRequest()

The sendRequest method handles authentication (IppOperation.kt:149), so it should work.

At the moment i think the issue may be due to a different context, because the basic auth relies on shared preferences. However, this would mean it would also fail on non-https connections. I have not yet been able to test this, since this app also needs an upgrade for all it's gradle files so that it works with newer android-studio versions